magento - Update All Product Attributes Programatically -


how can set value of given attribute same value products (efficiently)?

by efficient mean in 1 transaction, not having loop through entire product collection.

in past i've used mage_catalog_model_product_action bulk updates on products, , runs pretty fast

mage::getsingleton('catalog/product_action')     ->updateattributes($productids, array('some_attribute' => 'some_value'), 0) 

but requires specify product ids you're updating, creating huge where entity_id in(...) clause in mysql statement. there way everything?

i had same problem before, when added 11096 product(downloadable products) in store client told me add new attributes in product create 1 attribute (type yes/no) , set attribute set. problem how can iiedit product , set attribute yes or not. if don't set value null wrote few line code.

please check code may it'll helpful you.

$productid = mage::getresourcemodel('catalog/product_collection') - addattributetofilter('type_id', mage_downloadable_model_product_type::type_downloadable) - getallids(); //now create array of attribute_code => values  $attributedata = array("my_attribute_code" =>"my_attribute_value");  //set store affect. used admin change default values  $storeid = 0;  //now update attribute given products.  mage::getsingleton('catalog/product_action') ->updateattributes($productid, $attributedata, $storeid); 

it work me.i hope it'll work you


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -