agjjr Posted July 23, 2016 Share Posted July 23, 2016 Hi I am trying to do a simple CRUD in a module using MultiShop, but I am facing a strange behavior (maybe a bug). I am using PrestaShop 1.6.1.4. I have only one Model for my database, which has an multishop associated table. I used Shop::addTableAssociation('mytable', ['type' => 'shop']) to add the association to the PrestaShop core. My user is superadmin. I created a simple admin controller, with the $this->fields_form and $this->fields_list properties, but when I try to save data in the add action, the data is only created in the main table of the Model (the data is not created in the multishop associated table). Debugging the code, i noticed that when I call the d() function in some parts of the code, the data IS created in the associated table. When I remove the d() function, the associated data is no longer created. So I noticed that the associated data is being created, but strangely being removed in the function updateAssoShop() of the AdminController class, in the row 4327 of AdminController.php. Db::getInstance()->delete($this->table . '_shop', '`' . bqSQL($this->identifier) . '` = ' . (int) $id_object . ($exclude_ids ? ' AND id_shop NOT IN (' . implode(', ', array_map('intval', $exclude_ids)) . ')' : '')); Since I am using a superadmin user, the $exclude_ids array is empty, and so the condition for the delete statement is only '`' . bqSQL($this->identifier) . '` = ' . (int) $id_object and the multishop associated data previously created are being removed. Is this really a bug or did I understand something wrong about how to use multishop? Thanks in advance. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now