Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need modification for Bulk Import since Magento 2.4.1 #9

Open
0-Sony opened this issue Jan 21, 2021 · 4 comments
Open

Need modification for Bulk Import since Magento 2.4.1 #9

0-Sony opened this issue Jan 21, 2021 · 4 comments

Comments

@0-Sony
Copy link

0-Sony commented Jan 21, 2021

Magento version : 2.4.1

Edition (EE, CE, OS, etc): CE, EE

Expected behavior: bulk import works

Actual behavior: can't bulk import accessory product link type

Steps to reproduce:

Just import a csv file using the out of the box bulk import feature

Preconditions

Magento 2.4.1
php 7.4

Hi Magepal,

Currently working on Magento 2.4.1, you would need to update your module in order to make it working with this new Magento version.
The current patch needed for the import that you provide don't work anymore since the codebase has changed in Magento Core.

I suggest that you need to make a plugin to this method \Magento\CatalogImportExport\Model\Import\Product\LinkProcessor::addNameToIds in order to add your accessory product type

if you take a look on this class : \Magento\CatalogImportExport\Model\Import\Product

you will see this from line 225 :

    /**
     * Links attribute name-to-link type ID.
     *
     * @deprecated 101.1.0 use DI for LinkProcessor class if you want to add additional types
     *
     * @var array
     */
    protected $_linkNameToId = [
        '_related_' => \Magento\Catalog\Model\Product\Link::LINK_TYPE_RELATED,
        '_crosssell_' => \Magento\Catalog\Model\Product\Link::LINK_TYPE_CROSSSELL,
        '_upsell_' => \Magento\Catalog\Model\Product\Link::LINK_TYPE_UPSELL,
    ];

Regards.

@srenon
Copy link
Contributor

srenon commented Jan 21, 2021

@0-Sony ... thanks for reporting this issue.

Can you try this solution and let me know if it works?

In
app/code/MagePal/LinkProduct/etc/di.xml

add

    <type name="Magento\CatalogImportExport\Model\Import\Product\LinkProcessor">
        <arguments>
            <argument name="linkNameToId" xsi:type="array">
                <item name="_accessory_" xsi:type="const">MagePal\LinkProduct\Model\Product\Link::LINK_TYPE_ACCESSORY</item>
            </argument>
        </arguments>
    </type>

Let me know so I can release a new version

@0-Sony
Copy link
Author

0-Sony commented Jan 22, 2021

Hi @srenon ,

you would need also to add new key/value in this array \Magento\CatalogImportExport\Model\Import\Product::$_fieldsMap
You need to add a new Model Type in import.xml and use customFieldsMapping method.
Check this class \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType

it's used here $this->_fieldsMap = array_merge($this->_fieldsMap, $model->getCustomFieldsMapping()); line 1236 in \Magento\CatalogImportExport\Model\Import\Product

Regards

@srenon
Copy link
Contributor

srenon commented Jan 22, 2021

@0-Sony ... This going to take a while for me to get set up and figure out. Since you already have a handle on this you are more than welcome to create a Pull Request and I will merge it in.

@lbauche
Copy link

lbauche commented Feb 9, 2021

Hello,

I've got the same issue on same magento version.

I've simply overrided Class Magento\CatalogImportExport\Model\Import\Product througth di.xml to add :
in $_linkNameToId : '_accessory_' => \MagePal\LinkProduct\Model\Product\Link::LINK_TYPE_ACCESSORY,
in $_fieldsMap : '_accessory_sku' => 'accessory_skus', '_accessory_position' => 'accessory_position',

And it's working fine on v2.4.1 CE.

Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants