Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigurableAttributeHandler.php
Go to the documentation of this file.
1 <?php
7 
9 {
15  protected $collectionFactory;
16 
20  public function __construct(
21  \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory $attributeColFactory
22  ) {
23  $this->collectionFactory = $attributeColFactory;
24  }
25 
31  public function getApplicableAttributes()
32  {
34  $collection = $this->collectionFactory->create();
35  return $collection->addFieldToFilter(
36  'frontend_input',
37  'select'
38  )->addFieldToFilter(
39  'is_user_defined',
40  1
41  )->addFieldToFilter(
42  'is_global',
43  \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL
44  );
45  }
46 
52  {
53  $types = [
54  \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE,
55  \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL,
57  ];
58  return !$attribute->getApplyTo() || count(array_diff($types, $attribute->getApplyTo())) === 0;
59  }
60 }
__construct(\Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory $attributeColFactory)