Magento:批量更改产品商店 ID
我刚刚将大约 800 个产品导入 Magento,然后才意识到我将 store_id 设置为 0,而它本应为 1。
有谁知道更新此内容的简单方法吗?我尝试将电子表格中的 store_id 更改为 1 并再次导入以更新它们,但没有成功。
我在 http://www.magentocommerce.com/boards/viewthread/1798/< 找到了这个 SQL /a> 但我收到语法错误和未知列错误,所以我没有进一步处理它。
REPLACE INTO catalog_product_store (store_id, product_id) SELECT 1,entity_id from catalog_product_entity
update catalog_category_entity set store_id = 1 where store_id = 0;
update catalog_product_entity set store_id = 1 where store_id = 0;
update catalog_product_entity_datetime set store_id = 1 where store_id = 0;
update catalog_product_entity_decimal set store_id = 1 where store_id = 0;
update catalog_product_entity_gallery set store_id = 1 where store_id = 0;
update catalog_product_entity_int set store_id = 1 where store_id = 0;
update catalog_product_entity_text set store_id = 1 where store_id = 0;
update catalog_product_entity_tier_price set store_id = 1 where store_id = 0;
update catalog_product_entity_varchar set store_id = 1 where store_id = 0;
I've just imported ~800 products into Magento before realising I had store_id set to 0 when it should have been 1.
Does anyone know an easy way to update this? I've tried changing the store_id to 1 in the spreadsheet and importing it again to update them but it hasn't worked.
I found this SQL at http://www.magentocommerce.com/boards/viewthread/1798/ but I'm getting syntax errors and unknown column errors so I've not gone any further with it.
REPLACE INTO catalog_product_store (store_id, product_id) SELECT 1,entity_id from catalog_product_entity
update catalog_category_entity set store_id = 1 where store_id = 0;
update catalog_product_entity set store_id = 1 where store_id = 0;
update catalog_product_entity_datetime set store_id = 1 where store_id = 0;
update catalog_product_entity_decimal set store_id = 1 where store_id = 0;
update catalog_product_entity_gallery set store_id = 1 where store_id = 0;
update catalog_product_entity_int set store_id = 1 where store_id = 0;
update catalog_product_entity_text set store_id = 1 where store_id = 0;
update catalog_product_entity_tier_price set store_id = 1 where store_id = 0;
update catalog_product_entity_varchar set store_id = 1 where store_id = 0;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
商店 ID 0 是管理商店 - 在执行自定义导入时通常会设置此设置。除非您与多家商店合作,否则这不是问题。
更新产品的最快方法是转到“目录”->“管理产品”菜单,选择所有产品,然后选择“更新状态”并提交。然后,您可以在结果菜单的“网站”选项卡中分配网站关联。
批量编辑所有产品:

要使用代码来完成此操作,您需要循环遍历您的产品集合并设置网站或商店 ID那里。一个例子:
The store ID 0 is the admin store -- it's common to have this set when doing your custom imports. It's not a problem unless you are working with multiple stores.
The quickest way to update your products is to go to your Catalog->Manage Products menu, select all products, and then select "Update Status" and submit. Then you can assign the website association in the Websites tab on the resulting menu.
Bulk edit all products:

To do it with code instead, you would want to loop through your product collection and set the website or store id there. An example: