Prestashop - 更改数据库中的产品类别 [英] Prestashop - change product category in database
问题描述
我需要批量更改产品类别.我更新了数据库中的两个表:ps_category_product
(更改了旧的 id_category)和 ps_products
(更改了旧的 id_category_default)但在 BO 产品表和网上商店中我仍然看到旧的类别(主页).
I need to mass change product categories. I updated two tables in database: ps_category_product
(changed old id_category) and ps_products
(changed old id_category_default) but in BO product table and webshop I still see old category (home).
当我编辑产品时,选择标签关联我看到该产品与我的新类别相关联.只有当我通过单击保存按钮保存产品时,我才能在正确的类别中看到该产品.
When I edit product, select tab associations I see that product is associated with my new caterogy. Only when I save the product by click save button I see that product in properly categories.
我比较了数据库中的两行(mysql 查询更改了类别的产品和 BO 中更改的产品),这两行看起来相同.
I compared two rows in database (product with changed category by mysql query and product changed in BO) and these two look identical.
我做错了什么?我正在尝试清理缓存(删除缓存/cachefs 和 smarty/compile),禁用所有缓存选项但没有结果.
What am I doing wrong? I was trying clean cache (delete cache/cachefs and smarty/compile), disable all cache options but with no result.
推荐答案
要更改类别,必须执行以下查询:
To change the category, the following queries must be executed:
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'category_product SET id_category = NEW_ID_CATEGORY WHERE id_category = OLD_ID_CATEGORY');
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'product_shop SET id_category_default = NEW_ID_CATEGORY WHERE id_category_default = OLD_ID_CATEGORY AND id_shop = ID_SHOP');
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'product SET id_category_default = NEW_ID_CATEGORY WHERE id_category_default = OLD_ID_CATEGORY');
问候
这篇关于Prestashop - 更改数据库中的产品类别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!