Page 1 of 1

How to remove all relations ?

Posted: 16 Jan 2017, 02:07
by reptilee
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

Code: Select all

   
    $context = $this->app->make('\Aimeos\Shop\Base\Context')->get();
    $product_manager = \Aimeos\MShop\Factory::createManager($context, 'product');
    $product_manager->deleteItems( 5 );
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.

Re: How to remove all relations ?

Posted: 16 Jan 2017, 11:23
by aimeos
You are right, the Aimeos simple admin interface doesn't delete the references in the mshop_catalog_lists table. The expert mode admin interface does: https://github.com/aimeos/ai-admin-exta ... rd.php#L90

We will add this to the simple mode admin interface too.
Thanks for the hint!