collectionFactory = $attributeColFactory; } /** * Retrieve list of attributes applicable for configurable product * * @return \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection */ public function getApplicableAttributes() { /** @var $collection \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection */ $collection = $this->collectionFactory->create(); return $collection->addFieldToFilter( 'frontend_input', 'select' )->addFieldToFilter( 'is_user_defined', 1 )->addFieldToFilter( 'is_global', \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL ); } /** * @param \Magento\Catalog\Api\Data\ProductAttributeInterface $attribute * @return bool */ public function isAttributeApplicable($attribute) { $types = [ \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL, \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE, ]; return !$attribute->getApplyTo() || count(array_diff($types, $attribute->getApplyTo())) === 0; } }