How to remove all relations ?

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
reptilee
Posts: 3
Joined: 16 Jan 2017, 00:53

How to remove all relations ?

Post by reptilee » 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

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.

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: How to remove all relations ?

Post by aimeos » 16 Jan 2017, 11:23

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!
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply