几年前,我们的Magento商店里有11000多种产品,我们不得不稍微改变一下。
如果商店视图中使用的值(标题、启用/禁用、说明)可以覆盖默认值,而无需无休止的复制/粘贴,那么生活会更轻松。
因此,如果"商店视图值"与"默认值"不同,请将其设为"默认值。感谢帮助!
这可以直接用SQL完成,但一定要在启动之前设置维护模式和备份。
SET @default = 0;
SET @store = 1;
-- put the correct store_id here
START TRANSACTION;
INSERT INTO `catalog_product_entity_int` (entity_type_id, attribute_id, store_id, entity_id, value)
SELECT entity_type_id, attribute_id, @default, entity_id, value FROM `catalog_product_entity_int` AS local
WHERE store_id = @store
ON DUPLICATE KEY UPDATE value = local.value;
-- the "ON DUPLICATE..." part works because EAV tables have
-- a unique key for "entity_id, attribute_id, store_id"
DELETE FROM `catalog_product_entity_int`
WHERE store_id = @store;
-- it is safe to delete @store rows because all values
-- have been either copied or updated by now
COMMIT;
对所有catalog_product_entity_*
表重复上述操作。然后重建索引,您可以在站点处于SSH维护模式时执行此操作。。。
cd path/to/magento/shell/
php indexer.php --reindex catalog_product_attribute
我编写了一个PHP脚本,该脚本遍历storeview值,如果它们不同,则将它们复制到默认范围,然后删除本地值。
你可以在这里看到GIST:https://gist.github.com/janzikmund/a92e0a219af5e362fa1293b52b6b831e。
这是给你的意见。在底部,UPDATE和TRUNCATE行被注释掉了,所以您应该能够首先在不修改任何数据的情况下运行它,然后在确定取消注释这些行并转换数据时。
当然,别忘了先做备份!