Jump to content

When i delete a category, all the related products are deleted too


Recommended Posts

We had a category with five products. When we delete the category, the five products are deleted too. Is this a bug or a feature?

The products never should be deleted if i not say so. If i delete a category, all the related products must go to "home" category by default and disabled.

Link to comment
Share on other sites

Wrong ! Products are deleted. Just take a look at source code (Category.php Line 234)

/* Delete products which were\'t in others categories */
$result = Db::getInstance()->ExecuteS('
SELECT `id_product`
FROM `'._DB_PREFIX_.'product`
WHERE `id_product` NOT IN (SELECT `id_product` FROM `'._DB_PREFIX_.'category_product`)');
foreach ($result as $p)
{
$product = new Product(intval($p['id_product']));
if (Validate::isLoadedObject($product)) {
$product->delete();
}
}

Link to comment
Share on other sites

×
×
  • Create New...