0

I am trying to doing something like below.

1). Update Specific Attribute sets to Default. (It worked by using Extension on Git https://github.com/Flagbit/Magento-ChangeAttributeSet).

2). Now I also require to update configurable products with some new attribute. Like

Before I update attribute sets Old Attribute,Set has configurable products which all are created using lets say men_size.

Now After update it that attribute set to Default ALso need to update product with configurable attribute that is only size.

I managed to update size's value with old men_size. So after that custom script I've set value from men_size to size.

Size contains all values from men_size.

Afterwards I need to update all those configurable products to size attribute.

So All products has to be created using size attribute No more men_size.

Any idea to achieve this ??

$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addFieldToFilter('attribute_set_id',92);

foreach($products as $prod){
$_product = Mage::getModel('catalog/product')->load($prod->getData('entity_id'));
// get attribute text
$attrlabel = $_product->getAttributeText($attributeCode);
// get all options of Attribute
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $attributeCode_1); //"size" attribute_code
$allOptions = $attribute->getSource()->getAllOptions(true, true);
foreach($allOptions as $instance){
    if($attrlabel != ""){
        if($instance['label'] == $attrlabel){
            echo "-----------". $prod->getData('entity_id');
            $_product->setData('size',$instance['value']);
            $_product->save();
        }
    }
}
}

Your Answer

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

Browse other questions tagged or ask your own question.