我有一个Magento 1.5.0.1安装与3个不同的商店意见。在此过程中,有两个商店不使用产品属性的默认值。我试图找到一种方法让所有产品都使用所有商店的默认值,这样客户端只需要在一个地方进行更新。我发现this文章,但它似乎只适用于专门称为产品。任何人都可以解释如何在我的情况下使用该代码?或者建议新的代码?设置所有商品默认值全部商店
回答
我能得到这个工作的唯一办法是通过MySQL的:
DELETE FROM `catalog_product_entity_text` where store_id != 0;
DELETE FROM `catalog_product_entity_datetime` where store_id != 0;
DELETE FROM `catalog_product_entity_decimal` where store_id != 0;
DELETE FROM `catalog_product_entity_int` where store_id != 0;
DELETE FROM `catalog_product_entity_varchar` where store_id != 0;
以上将重置所有产品中使用默认值的所有属性。
这工作伟大的人感谢! – 2013-04-03 17:31:31
您应该使用Mage :: getSingleton('catalog/product_action')来更新连续的很多产品。
1°)得到你想要的产品的ID,对所有产品使用:
$ids = Mage::getModel('catalog/product')->getCollection()->getAllIds();
2°)使属性的列表和值相关联的 “假”
$attributes = array('name'=>false,'description'=>false,....)
3°)拿起店内的ID列表改变,并将其设置在数组中太:
$stores = array(1,2,3);
然后创建脚本:
foreach ($stores as $store_id)
{
Mage::getSingleton('catalog/product_action')->updateAttributes($ids, $attributes, $store_id);
}
将所有产品都更新(IDS)来设置属性在STORE_ID默认(感谢“假”值)。
好的,我在这里创建了我的脚本文件:http://pastebin.com/yc9BY8XC和我上传到我的magento根,制作可执行文件并运行它,但我得到错误。你能帮我弄清楚这个想法吗? – 2013-03-04 19:38:48
你可以尝试只有一个属性?你有什么错误信息? – dagfr 2013-03-04 20:38:17
我试图从SSH会话中运行它,它给了我没有任何意义的错误。然后,我使用网络浏览器浏览文件,脚本似乎运行,因为现在商店没有在前端显示任何产品。该脚本似乎清除了所有产品上的所有字段,但未检查“使用默认值”框。有任何想法吗?我的完整脚本在这里:http://pastebin.com/fpv6qxGi – 2013-03-05 22:10:52
这将需要已设置的任何存储值和合并那些到默认值的所有产品:
<?php
$cat = mysql_connect("host", "user", "password") or die(mysql_error());
mysql_select_db("database",$cat) or die(mysql_error());
$types = array(
'catalog_product_entity_text',
'catalog_product_entity_datetime',
'catalog_product_entity_decimal',
'catalog_product_entity_int',
'catalog_product_entity_varchar'
);
foreach($types as $type){
$result = mysql_query("select * from $type where store_id != 0",$cat) or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
if(!is_null($row['value'])){
mysql_query("update $type set value = '".mysql_real_escape_string(stripslashes($row['value']))."'
where store_id = '0'
and entity_id = '".$row['entity_id']."'
and attribute_id = '".$row['attribute_id']."'",$cat) or die(mysql_error());
}
mysql_query("delete from $type where value_id = '".$row['value_id']."'",$cat) or die(mysql_error());
}
}
?>
- 1. 将商店视图图像设置复制到默认设置
- 2. 如何设置全局商店对象?
- 3. 列出发行商在Play商店的所有产品
- 4. 根据商店位置搜索商店产品
- 5. 如何在Ember.js中将默认商店设置为FixtureAdapter?
- 6. Magento:为国家magento设置默认商店视图
- 7. 如何在magento中设置$默认商店ID或默认网站
- 8. Prestashop多商店设置
- 9. CodeGear Delphi 2009商店设置
- 10. 如何启用所有商店中的所有产品
- 11. Sencha Touch - 动态设置商店代理网址,并将商店加载到商品列表中
- 12. Magento的:设置时,你有默认主页/存储多个商店
- 13. 使用opencart获取多商店设置的商店ID
- 14. Android商店中缺少Google Play商店物品
- 15. 如何从Google Play商店中检索所有应用内购商品
- 16. python商店新值
- 17. extjs 6全球商店包
- 18. 更新全部商品(缺货时)Prestashop
- 19. 为一个商店设置每个产品的两个价格
- 20. BigCommerce - 网格商店内所有品牌的列表
- 21. 查找所有商店的产品总库存量
- 22. 以编程方式为当前商店设置默认国家/地区,magento?
- 23. 设置envif主机Magento多个商店
- 24. 如何设置wordpress主题商店?
- 25. 设置localStorage的商店嵌套列表
- 26. 德国Magento网上商店设置
- 27. 将商店视图设置为
- 28. NSPredicate所有集合使用SQLite商店
- 29. 如何迭代所有商店?
- 30. 获取所有厂商特定的商店
您有任何想法条目其他商店创建时。 – 2013-05-07 12:57:20