有没有办法将商店视图值传输到Magento中的默认值?

时间:2014-09-18 14:33:13

标签: magento default overwrite

我们在Magento商店购买了几年和11,000多种产品,我们不得不改变一下。

如果商店视图中使用的值(标题,启用/禁用,描述)可以覆盖默认值而无需无休止的复制/粘贴时间,那么生活会更容易。

因此,如果商店视图值与默认值不同,请将其设为默认值。帮助赞赏!

2 个答案:

答案 0 :(得分:1)

这可以直接使用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

答案 1 :(得分:0)

我编写了一个PHP脚本,它遍历了storeview值,如果它们不同,则将它们复制到默认范围,然后删除本地值。

您可以在此处查看GIST:https://gist.github.com/janzikmund/a92e0a219af5e362fa1293b52b6b831e

可以给您一个主意。在UPDATE和TRUNCATE行的底部被注释掉,因此您应该能够首先运行它而无需进行任何数据修改,然后在确定取消注释这些行并转换数据时就可以运行它。

当然不要忘了先备份!