-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Labels
Component: CatalogFixed in 2.1.xThe issue has been fixed in 2.1 release lineThe issue has been fixed in 2.1 release lineFixed in 2.2.xThe issue has been fixed in 2.2 release lineThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineThe issue has been fixed in 2.3 release lineIssue: Cannot ReproduceCannot reproduce the issue on the latest `2.4-develop` branchCannot reproduce the issue on the latest `2.4-develop` branchIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedGate 2 Passed. Manual verification of the issue description passedIssue: Format is not validGate 1 Failed. Automatic verification of issue format is failedGate 1 Failed. Automatic verification of issue format is failedProgress: needs updatebug report
Description
Steps to reproduce
- Make sure that you have an attribute that is of type "swatches"
- Make sure that this attribute does not have any option / swatch
- Try to add a swatch option using
\Magento\Catalog\Api\ProductAttributeOptionManagementInterface::add
Expected result
The attribute from step 1 above should have a new swatch option.
Actual result
An exception is thrown: "Cannot save attribute [code of the attribute from step 1 above]"
This comes from \Magento\Eav\Model\Entity\Attribute\OptionManagement::add
because, on \Magento\Swatches\Model\Plugin\EavAttribute::prepareOptionLinks
, $attributeSavedOptions[$optionCounter]
is never set ($attributeSavedOptions[1]
fails).
Fix
\Magento\Swatches\Model\Plugin\EavAttribute::prepareOptionLinks
should be like this:
protected function prepareOptionLinks(array $optionsArray, array $attributeSavedOptions)
{
$dependencyArray = [];
$optionCounter = 1;
if (is_array($optionsArray['value']) && isset($attributeSavedOptions[$optionCounter])) {
foreach (array_keys($optionsArray['value']) as $baseOptionId) {
$dependencyArray[$baseOptionId] = $attributeSavedOptions[$optionCounter]['value'];
$optionCounter++;
}
}
$this->dependencyArray = $dependencyArray;
}
Github extension while waiting for the fix to be implemented
giacmir, MidnightDesign and antoinekociuba
Metadata
Metadata
Assignees
Labels
Component: CatalogFixed in 2.1.xThe issue has been fixed in 2.1 release lineThe issue has been fixed in 2.1 release lineFixed in 2.2.xThe issue has been fixed in 2.2 release lineThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineThe issue has been fixed in 2.3 release lineIssue: Cannot ReproduceCannot reproduce the issue on the latest `2.4-develop` branchCannot reproduce the issue on the latest `2.4-develop` branchIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedGate 2 Passed. Manual verification of the issue description passedIssue: Format is not validGate 1 Failed. Automatic verification of issue format is failedGate 1 Failed. Automatic verification of issue format is failedProgress: needs updatebug report