如何直接从Magento数据库表中删除I禁用或特定产品?
需要在phpmyadmin中运行的查询是什么?或者我需要更新哪些表?
答案 0 :(得分:0)
是直接在DB中是一个危险的举动。以编程方式删除已禁用产品的最简单方法是:
这假设您没有使用多商店,其中产品在每个商店视图中可能具有不同的状态。
使用此代码创建一个php文件;
include_once "app/Mage.php";
Mage::init();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); // This gives us the rights to delete
$collection = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('status', array('neq' => 1)) // only get disabled
->load();
foreach($collection as $_product) {
echo 'Deleting: '.$product->getName().'<br />';
$_product->delete();
}
将此代码放入Magento root direcory并通过浏览器调用它。为了自动化,我建议将它放在你的shell目录中(不要忘记修改app / mage的路径),并且每晚都要通过cron调用它。