Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Configurable.php
Go to the documentation of this file.
1 <?php
7 
11 
13 {
17  private $eavConfig;
18 
22  private $swatchHelper;
23 
28  public function __construct(
29  \Magento\Eav\Model\Config $eavConfig,
30  \Magento\Swatches\Helper\Data $swatchHelper
31  ) {
32  $this->eavConfig = $eavConfig;
33  $this->swatchHelper = $swatchHelper;
34  }
35 
45  ConfigurableProductType $subject,
48  ) {
49  $swatchAttributes = ['image'];
50  foreach ($subject->getUsedProductAttributes($product) as $code => $attribute) {
51  if ($attribute->getData('additional_data')
52  && (
53  $this->swatchHelper->isVisualSwatch($attribute) || $this->swatchHelper->isTextSwatch($attribute)
54  )
55  ) {
56  $swatchAttributes[] = $code;
57  }
58  }
59  $result->addAttributeToSelect($swatchAttributes);
60  return $result;
61  }
62 }
__construct(\Magento\Eav\Model\Config $eavConfig, \Magento\Swatches\Helper\Data $swatchHelper)
afterGetUsedProductCollection(ConfigurableProductType $subject, Collection $result, ProductInterface $product)
$code
Definition: info.phtml:12