4

Yesterday I run into an issue while creating configurable products with our custom import task. It seems that Magento requires configurable attributes to be user_defined. So, what happens with attributes created programmatically defined as system attributes to avoid the admin users to edit them?

Is this just a bug or there is a reason behind it?

class Magento\ConfigurableProduct\Model\Product\Type\Configurable

    /**
     * Check attribute availability for super product creation
     *
     * @param  \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute
     * @return bool
     */
    public function canUseAttribute(\Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute)
    {
        return $attribute->getIsGlobal() == \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL &&
            $attribute->getIsVisible() &&
            $attribute->usesSource() &&
            $attribute->getIsUserDefined();
    }
1
  • my money is on "There is a reason behind it" because there is that specific && $attribute->getIsUserDefined() in there, but I don't have the reason. Good question. – Marius Oct 5 '16 at 8:12
2

System attributes by default applied to all group and attribute sets and if you will create configurable attribute it will not for all groups you have created.

That is the reason why then applied

$attribute->getIsUserDefined()

in if condition to check.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.