我有一个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. Magento删除默认商店视图的商店代码
- 3. 设置商品属性在商店层面在magento multistore
- 4. 如何设置全局商店对象?
- 5. 列出发行商在Play商店的所有产品
- 6. Magento:为国家magento设置默认商店视图
- 7. 如何在Ember.js中将默认商店设置为FixtureAdapter?
- 8. 如何在Demandware中设置默认商店图像
- 9. 根据商店位置搜索商店产品
- 10. 如何在magento中设置$默认商店ID或默认网站
- 11. 商店小部件位置
- 12. Play商店下载到所有设备?
- 13. 网站magento默认商店ID
- 14. 如何从商店设置值extjs4
- 15. Prestashop多商店设置
- 16. Php商店小时 - 设置
- 17. CodeGear Delphi 2009商店设置
- 18. 搜索Dojo商店内的商品
- 19. Magento多店 - 展示所有商店的产品
- 20. 如何启用所有商店中的所有产品
- 21. Windows应用商店 - 所选商品的Gridview背景颜色
- 22. PHP商店值
- 23. 在我的新商店视图中使用来自我的默认商店的所有图像
- 24. Magento的:设置时,你有默认主页/存储多个商店
- 25. 在组合框中的默认值作为商店的值
- 26. Sencha Touch - 动态设置商店代理网址,并将商店加载到商品列表中
- 27. 凡商店用户设置的iOS - 应用程序商店
- 28. 如何获得Drupal 8商店的商店设置
- 29. 使用opencart获取多商店设置的商店ID
- 30. RavenDB没有设置商店的所有属性
您有任何想法条目其他商店创建时。 – 2013-05-07 12:57:20