0

Trying to delete a configurable product attribute and it comes up with a "This attribute is used in configurable products." Error.

The product associated with this attribute is now disabled but we don't really want to delete it if we can help it (we want to keep a record of this for customers). We need to delete these as we have almost 200 configurable attributes like this. This becomes really slow with 2 stores and 300+ attributes when loading a product (Mage::getModel('catalog/product')->load($id) // all attributes loaded).

I was wondering if there is there away to either stop Magento from loading all configurable product attributes not associated with the product when load() is called or reduce the number of configurable attributes we have without deleting the products. (Perhaps we could create a single dummy attribute to replace all the configurable product attribute that we don't use) ?

Any ideas?

Thanks in Advance,

  • You can delete the attribute in eav_attribute and then heavily test this. I don't think this will work and there will be errors you don't find while testing. But this is the dark path you can go. – Fabian Blechschmidt Oct 23 '14 at 14:42
2

When you have some configurable products created on the basis of that attribute you can't delete the attribute. But if you want to really delete that attribute, you have to delete the products first.
You will not find any hacky method for it. These attributes are saved in eav attribute table and products just get its id (attribute_id) to relate. so if you delete the attribute, you will face errors like "something is being load non-object..." etc, and you may even not be able to edit that product at backend nor it will load at frontend. so be cautious before committing such things on live.

  • I knew this would be the case but I was hoping someone else had a hackey work around. – Danny Dev Nz Jul 8 '14 at 1:25
0

I hope this code will help you to get product with only essential attributes or you can control over attributes by filter.

$configProduct = Mage::getModel("catalog/product")
                    ->getCollection()
                    //->addAttributeToSelect('*')
                    ->addAttributeToFilter('sku', array("YOUR_PRODUCT_SKU"))
                    ->addAttributeToFilter('type_id', array('eq' => 'configurable'))
                    ->load();

print_r($configProduct->getFirstItem());

you can remove comment from addAttributeToSelect('*') and provide attribute codes in array which you want to load in collection.

Loading whole collection for just one product is not recommended but you can filter in your collection and get only those things which you want.

Please keep in mind this code is answer of

I was wondering if there is there away to either stop Magento from loading all configurable product attributes when load() is called or reduce the number of configurable attributes without deleting the products.

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.