在Magento上有很多关于这个问题的帖子。它们中的大多数都可以工作,但是类别在执行delete代码/SQL语句后没有将它们的值重置为零的问题仍然存在,直到现在还没有得到解决。
在座的任何人都有正确的代码或程序,可以正确地从库存中删除所有产品,并在执行后将类别列表也重置为零?
提前谢谢。
发布于 2012-01-18 10:53:41
不管用于删除产品的方法是什么,重建"Category products“索引应该可以修复计数。转到系统>索引管理。选中"Category Products“旁边的复选框,将操作(右上角)更改为"Reindex”,然后单击submit。
发布于 2012-11-09 22:35:26
从Magento中删除所有产品都很容易,只需运行:
DELETE FROM `catalog_product_entity`
由于Magento的数据库中设置了外键约束,因此可以很好地清理其中包含产品信息的所有其他表。当然,删除很多产品需要一些时间,但至少会得到很好的清理。
如果查询因为最大执行时间而无法运行,则可以始终运行以下命令:
DELETE FROM `catalog_product_entity` LIMIT 10000
更新:这个逻辑也被用在了Magento的核心中,所以使用起来很安全!https://github.com/OpenMage/magento-mirror/blob/magento-1.8/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php#L462
发布于 2012-01-18 15:57:04
要删除所有产品,您可以使用以下查询:
TRUNCATE TABLE `catalog_product_bundle_option`;
TRUNCATE TABLE `catalog_product_bundle_option_value`;
TRUNCATE TABLE `catalog_product_bundle_selection`;
TRUNCATE TABLE `catalog_product_entity_datetime`;
TRUNCATE TABLE `catalog_product_entity_decimal`;
TRUNCATE TABLE `catalog_product_entity_gallery`;
TRUNCATE TABLE `catalog_product_entity_int`;
TRUNCATE TABLE `catalog_product_entity_media_gallery`;
TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;
TRUNCATE TABLE `catalog_product_entity_text`;
TRUNCATE TABLE `catalog_product_entity_tier_price`;
TRUNCATE TABLE `catalog_product_entity_varchar`;
TRUNCATE TABLE `catalog_product_link`;
TRUNCATE TABLE `catalog_product_link_attribute`;
TRUNCATE TABLE `catalog_product_link_attribute_decimal`;
TRUNCATE TABLE `catalog_product_link_attribute_int`;
TRUNCATE TABLE `catalog_product_link_attribute_varchar`;
TRUNCATE TABLE `catalog_product_link_type`;
TRUNCATE TABLE `catalog_product_option`;
TRUNCATE TABLE `catalog_product_option_price`;
TRUNCATE TABLE `catalog_product_option_title`;
TRUNCATE TABLE `catalog_product_option_type_price`;
TRUNCATE TABLE `catalog_product_option_type_title`;
TRUNCATE TABLE `catalog_product_option_type_value`;
TRUNCATE TABLE `catalog_product_super_attribute`;
TRUNCATE TABLE `catalog_product_super_attribute_label`;
TRUNCATE TABLE `catalog_product_super_attribute_pricing`;
TRUNCATE TABLE `catalog_product_super_link`;
TRUNCATE TABLE `catalog_product_enabled_index`;
TRUNCATE TABLE `catalog_product_website`;
TRUNCATE TABLE `catalog_product_entity`;
TRUNCATE TABLE `cataloginventory_stock`;
TRUNCATE TABLE `cataloginventory_stock_item`;
TRUNCATE TABLE `cataloginventory_stock_status`;
INSERT INTO `catalog_product_link_type`(`link_type_id`,`code`) VALUES (1,'relation'),(2,'bundle'),(3,'super'),(4,'up_sell'),(5,'cross_sell');
INSERT INTO `catalog_product_link_attribute`(`product_link_attribute_id`,`link_type_id`,`product_link_attribute_code`,`data_type`) VALUES (1,2,'qty','decimal'),(2,1,'position','int'),(3,4,'position','int'),(4,5,'position','int'),(6,1,'qty','decimal'),(7,3,'position','int'),(8,3,'qty','decimal');
INSERT INTO `cataloginventory_stock`(`stock_id`,`stock_name`) VALUES (1,'Default');
致敬:)
https://stackoverflow.com/questions/8899366
复制相似问题