When I edit a configurable product
in the Configuration section
, it shows the list of all the configurations.
I want to disable one of the products listed there so when I choose Disable Product
the status does change to "Disabled".
But after saving the product, status changes back to Enabled
.
I have the error logs enabled but no error message
appears there even when I have cleared the cache and reindexed.
Best Answer
Problem solved. After I've tried to change simple products statuses, from the configurable product grid, I've encountered the same problem. Seems to be a magento bug.
The story
Before saving the informations about configurable product, there are initialised the informations about simple products belonging to it. This is happening in
module-configurable-product/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurations.php
file, following function:Here, the simple products are iterated and if a product contains
was_changed
, in the array informations, it is added in the$result
array to be saved in the database.The problem: Even if I change the status for a simple product, the
was_changed
attribute is not set for it, in the informations which will be received by the "save" controller. So, when the simple items are iterated ingetConfigurationsFromProduct
function, thecontinue
statement will be hit every time,$result
array being null.The solution:
I've found a way to set
was_changed
attribute, in thetoggleStatusProduct
function frommodule-configurable-product/view/adminhtml/web/js/components/dynamic-rows-configurable.js
, which is dispatched every time the simple product status is changed. The cleanest way is to rewrite that file and replace the function with:Clear the cache, run a deploy and it should work.
Good luck !