Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be able to edit large config products in backend #39

Open
peterjaap opened this issue Apr 5, 2019 · 6 comments
Open

Be able to edit large config products in backend #39

peterjaap opened this issue Apr 5, 2019 · 6 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@peterjaap
Copy link
Contributor

peterjaap commented Apr 5, 2019

...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.

@peterjaap peterjaap pinned this issue Apr 5, 2019
@peterjaap peterjaap added enhancement New feature or request help wanted Extra attention is needed labels Apr 5, 2019
@zaiatsFlagbit
Copy link

Hi @peterjaap
Facing the same problem. Large configurable products 3k+
Did you consider paginating dataSet? not to load huge xml attaching json to document?

@peterjaap
Copy link
Contributor Author

@zaiatsFlagbit no I hadn't considered that.

We're not using this extension anymore bytheway, @gaiterjones took over maintaining it.

@gaiterjones
Copy link
Collaborator

@zaiatsFlagbit I think paginating the variation data could be an option so the user loads the variations manually per variation page click.

I have not worked with a configurable product with more than 1000 variations before so have not seen any memory problems whilst creating variation data.

Can you provide more info as to your server RAM config, how much mem is available to PHP?

@zaiatsFlagbit
Copy link

@gaiterjones I created a module, implementing pagination for Large_Configurable_Products.
I override Data_Provider, which forms product-matrix, slicing it in peaces by offset and limit params from FE. The dynamic-rows-extended.js holds some logic for pagination requests.

@gaiterjones
Copy link
Collaborator

@zaiatsFlagbit your module looks very interesting, great work - did you test it with this module too or are you happy to simply paginate the variations to improve loading? I will test it as soon as can.

@zaiatsFlagbit
Copy link

@gaiterjones - yes, I am using elgentos module alongside, but not as a dependency. At the moment testing new module flow. Upcoming changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants