<?xml version="1.0"?>
<!--
/**
 * @author Amasty Team
 * @copyright Copyright (c) Amasty (https://www.amasty.com)
 * @package Product Import Entity for Magento 2 (System)
 */-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:amasty:module:Amasty_ImportCore:etc/am_import.xsd">
    <entity code="downloadable_link_title">
        <name>Downloadable Product Title</name>
        <group>Product</group>
        <description>Downloadable Link Title Import Entity</description>
        <enabledChecker class="Amasty\ImportCore\Import\Config\IsModuleEnabled">
            <arguments>
                <argument name="moduleName" xsi:type="string">Magento_Downloadable</argument>
            </arguments>
        </enabledChecker>
        <fieldsConfig>
            <fieldsClass class="Amasty\ImportCore\Import\FieldsClass\Describe">
                <arguments>
                    <argument name="tableName" xsi:type="string">downloadable_link_title</argument>
                </arguments>
            </fieldsClass>
            <fields>
                <field name="title_id">
                    <actions>
                        <trim/>
                    </actions>
                    <validation>
                        <integer/>
                        <greaterThanZero/>
                    </validation>
                </field>
                <field name="link_id">
                    <actions>
                        <trim/>
                    </actions>
                    <validation>
                        <integer/>
                        <greaterThanZero/>
                    </validation>
                </field>
                <field name="store_id">
                    <validation>
                        <storeExists/>
                    </validation>
                    <filter>
                        <type>store</type>
                    </filter>
                </field>
            </fields>
            <sampleData>
                <row>
                    <field name='title_id'>1</field>
                    <field name='link_id'>1</field>
                    <field name='store_id'>1</field>
                    <field name='title'>Link Title</field>
                </row>
                <row>
                    <field name='title_id'>2</field>
                    <field name='link_id'>2</field>
                    <field name='store_id'>1</field>
                    <field name='title'>Link with URL resources</field>
                </row>
            </sampleData>
        </fieldsConfig>
        <behaviors>
            <addUpdateDirect name="Add/Update">
                <tableName>downloadable_link_title</tableName>
                <idField>title_id</idField>
            </addUpdateDirect>
            <addDirect name="Only add">
                <tableName>downloadable_link_title</tableName>
                <idField>title_id</idField>
            </addDirect>
            <updateDirect name="Only update">
                <tableName>downloadable_link_title</tableName>
                <idField>title_id</idField>
            </updateDirect>
            <deleteDirect name="Delete">
                <tableName>downloadable_link_title</tableName>
                <idField>title_id</idField>
            </deleteDirect>
        </behaviors>
    </entity>
    <relation code="downloadable_link_link_title">
        <parent_entity>downloadable_link</parent_entity>
        <child_entity>downloadable_link_title</child_entity>
        <sub_entity_field_name>downloadable_link_title</sub_entity_field_name>
        <type>one_to_one</type>
        <arguments>
            <argument name="parent_field_name" xsi:type="string">link_id</argument>
            <argument name="child_field_name" xsi:type="string">link_id</argument>
        </arguments>
    </relation>
</config>
