在Magento的所有产品默认属性值 [英] Default attribute value for all product in magento
本文介绍了在Magento的所有产品默认属性值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要为所有产品的属性的默认值。
I want to set a default value of an attribute for all product.
推荐答案
我以前同样的问题,当我在我的商店增加11096产品(下载产品),然后客户端告诉我加在产品新的属性,所以我创建1属性(类型是是/否),并设置为属性集。
现在我的问题是如何编辑的所有产品,并设置该属性是或not.if我不会设置值为空,所以我写了几行code。
I had same problem before,when i added 11096 product(downloadable products) in my store then client told me to add new attributes in product so i create 1 attribute (Type is Yes/No) and set to attribute set. Now my problem is how can i edit all product and set that attribute yes or not.if i not set then value is null so i wrote few line code.
请检查该code可能是它会帮助你。
Please check this code may be it'll helpful to you.
$ProductId = Mage::getResourceModel('catalog/product_collection')
->addAttributeToFilter('type_id', Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE)
->getAllIds();
//Now create an array of attribute_code => values
$attributeData = array("my_attribute_code" =>"my_attribute_value");
//Set the store to affect. I used admin to change all default values
$storeId = 0;
//Now Update the attribute for the given products.
Mage::getSingleton('catalog/product_action')
->updateAttributes($ProductId, $attributeData, $storeId);
这篇关于在Magento的所有产品默认属性值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文