How to remove all relations ?
Posted: 16 Jan 2017, 02:07
Let's say I create a product, and assign it to a catalog.
In this case, the mshop_catalog_list will contain the relation between the catalog and the product.
What I noticed, if I delete a certain product from the database, it will delete all its relations from the from mshop_product_list as well. However the relations are not deleted from mshop_catalog_list.
For example if I have a product with ID 5 and then I use
It will delete all the relations from mshop_product_list where 'parentid' is 5 (since parentid is a foreign key with cascade)
But mshop_catalog_list will still have a row with 'refid' 5. And that's invalid becuase that item is deleted already.
I tried the same from the admin area, I created a product on the user interface, assign to a catalog. Then I deleted it, checked the database, and those rows with 'refid' still there, cause it's not a foreign key.
In this case, the mshop_catalog_list will contain the relation between the catalog and the product.
What I noticed, if I delete a certain product from the database, it will delete all its relations from the from mshop_product_list as well. However the relations are not deleted from mshop_catalog_list.
For example if I have a product with ID 5 and then I use
Code: Select all
$context = $this->app->make('\Aimeos\Shop\Base\Context')->get();
$product_manager = \Aimeos\MShop\Factory::createManager($context, 'product');
$product_manager->deleteItems( 5 );
But mshop_catalog_list will still have a row with 'refid' 5. And that's invalid becuase that item is deleted already.
I tried the same from the admin area, I created a product on the user interface, assign to a catalog. Then I deleted it, checked the database, and those rows with 'refid' still there, cause it's not a foreign key.