Prestashop - change product category in database

北城以北 提交于 2019-12-12 05:53:50

问题


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.

I compared two rows in database (product with changed category by mysql query and product changed in BO) and these two look identical.

What am I doing wrong? I was trying clean cache (delete cache/cachefs and smarty/compile), disable all cache options but with no result.


回答1:


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');

Regards



来源:https://stackoverflow.com/questions/44087875/prestashop-change-product-category-in-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!