22 private $typeConfigurable;
27 private $swatchAttributeCodes;
33 private $attributesPerProduct;
38 private $swatchTypeChecker;
50 $this->typeConfigurable = $typeConfigurable;
51 $this->swatchAttributeCodes = $swatchAttributeCodes;
52 $this->swatchTypeChecker = $swatchTypeChecker
68 if (!isset($this->attributesPerProduct[
$product->getId()])) {
69 $configurableAttributes = $this->typeConfigurable->getConfigurableAttributes(
$product);
70 $swatchAttributeCodeMap = $this->swatchAttributeCodes->getCodes();
72 $swatchAttributes = [];
73 foreach ($configurableAttributes as $configurableAttribute) {
74 if (array_key_exists($configurableAttribute->getAttributeId(), $swatchAttributeCodeMap)) {
76 $productAttribute = $configurableAttribute->getProductAttribute();
77 if ($productAttribute !==
null 78 && $this->swatchTypeChecker->isSwatchAttribute($productAttribute)
80 $swatchAttributes[$configurableAttribute->getAttributeId()] = $productAttribute;
84 $this->attributesPerProduct[
$product->getId()] = $swatchAttributes;
86 return $this->attributesPerProduct[
$product->getId()];
__construct(Configurable $typeConfigurable, SwatchAttributeCodes $swatchAttributeCodes, SwatchAttributeType $swatchTypeChecker=null)