firegento/FireGento_ExtendedImport2

New attribute options cannot be used immediately

Closed this issue · 3 comments

Hi,

I am importing configurable products and the simples that belong to it. Some simples have attribute values that do not exist yet. The options are created as expected, but when the products are saved they fail to pass the validation phase. The error received is:

Invalid option value in row(s): 19

When I attempt the import again it succeeds, since the options have been added correctly.

The problem relates to this comment in the code:

// Delete Common Attributes Cache, for forcing reloading the Values

It seems to me that this clearing of the in-request cache does not work anymore in Magento 2.1.7. I have not been able to fix it myself.

Magento 2.1.7

Addition: the attribute that causes the problem is a super attribute, it links the simple to the configurable

This is because vendor/magento/module-eav/Model/Config.php:505 has an internal attributes cache:

if (isset($this->attributes[$entityTypeCode][$code])) {
    return $this->attributes[$entityTypeCode][$code];
}

So in vendor/firegento/extendedimport/Plugin/CreateMissingAttributeOptionPlugin.php we have createAttributeOption which does create the option if it is not found, but then tries to retrieve the option again with the Config model:

$option = $this->findAttributeOptionByLabel($attributeCode, $label);

Which still has the old attribute option data I think.

Still not working!