-
Notifications
You must be signed in to change notification settings - Fork 30
Description
...by removing the variations matrix in the edit screen. Here's some work on it I did so far;
Comment out in vendor/magento/module-configurable-product/etc/adminhtml/di.xml to remove the matrix variations grid from the product edit screen in the backend for configurables;
<virtualType name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Pool">
<arguments>
<argument name="modifiers" xsi:type="array">
<item name="configurable" xsi:type="array">
<item name="class" xsi:type="string">Magento\ConfigurableProduct\Ui\DataProvider\Product\Form\Modifier\Composite</item>
<item name="sortOrder" xsi:type="number">140</item>
</item>
</argument>
</arguments>
</virtualType>
Edit the PHP class that retrieves the variations (this is the memory culprit); \Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Variations\Config\Matrix::getVariations add; return [];
Then we need to fix a small JS validation error: vendor/magento/module-configurable-product/view/adminhtml/web/js/variations/variations.js::exports.changeButtonWizard line 183 change to; if (this.variations && this.variations.length) {
This is where the simple products are connected to the configurable when it is saved; \Magento\ConfigurableProduct\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Configurable::afterInitialize, that's a plugin for \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper::initialize
\Magento\Catalog\Controller\Adminhtml\Product:100 is where Magento builds up the product according to the POST request. The changes we just did cause Magento to de-couple the simples from the configurable since the POST param is empty.
In \Magento\ConfigurableProduct\Model\Product\TypeTransitionManager\Plugin\Configurable::aroundProcessProduct the configurable products is transitioned to a simple product since the attributes field is empty.
So we need to comment out $this->productTypeManager->processProduct($product); in \Magento\Catalog\Controller\Adminhtml\Product\Save to make sure a configurable product isn't converted to a simple product, which causes the product relations to be removed.
It would be great if we can do the above based on the number of childs the configurable have, and make this a configurable setting. For me, about 3000 products is where the server throws a memory limit error but this could be different for another server.
Obviously, this is just the happy path. I haven't done any testing at all whether it affects other parts of Magento.