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

Akeneo 2 product variants doesn't import right way to Magento 2.2 if there is more than one level #168

Open
rainmikko opened this issue Jan 19, 2018 · 5 comments

Comments

@rainmikko
Copy link

Hi,

I have played some time with Akeneo 2 and Magento 2.2 and I can't get product import working right way.

For simple products import worked quite good, but when I import product with variants, there is some problems.

I tried it with Akeneo demo data and empty Magento so this is easily reproducable.

Family "Clothing" has variant family "Clothing by color and size". That variant family have color in first variant axis and size in second variant axis. Like this:
akeneo_variants_clothing

Then I have product model which has that variant family:
akeneo_product_variant

When I export those products to Magento, PIMGento creates "Configurable" product to that first variant axis level. Here is screenshot from Magento:
divided_list

So, it creates "Configurable" product for each color of the t-shirt. That could be acceptable, if it doesn't add that color-attribute to configurable attributes. Because of that, when customer tries to add item in cart, they have to choose both color and size. Like this:
grey
And this:
red

Is that behaviour customisable in PIMGento somehow? I can live with "Configurable" product for each color of t-shirt, if that color attribute is not mandatroy to choose.

Best solution is, that PIMGento somehow creates one "Configurable" product, which have both attributes choosable (color and size). Like this example product which I created straight to Magento:
magento_configurable_option1
magento_configurable_option2

@ruihua1970
Copy link

I have the same problem:-(

@toweb7
Copy link

toweb7 commented Apr 20, 2018

I stacked on the same issue and it is a real problem for our Magento 2 project.

@toweb7
Copy link

toweb7 commented Apr 23, 2018

I stacked with the same problem and implemented the solution by overriding the method "createConfigurable" in Pimgento\Product\Model\Factory\Import

The main idea is to read the same "pimgento_variant" table and for 2 axes firstly find all children "configurable" products and ONLY then from them collect all simple product SKUs into one column "_children" looking into "tmp_pimgento_entities_product".

As we can have 1 or 2 axes I use COALESCE to have all results in one column "_children". The SQL query can be optimised, but I hope it idea can help you.

I changes 340-348 line ($configurable = $connection->select() ...) to

// Fixed solution for configurable products
            $pimgentoVariantTable = $resource->getTable('pimgento_variant');
            $select1 = 'SELECT GROUP_CONCAT(sku SEPARATOR ",") FROM `' . $tmpTable . '` WHERE FIND_IN_SET(parent, (SELECT GROUP_CONCAT(code SEPARATOR ",") FROM `' . $pimgentoVariantTable . '` WHERE parent = v.code GROUP BY parent))';
            $select2 = 'SELECT GROUP_CONCAT(sku SEPARATOR ",") FROM `' . $tmpTable . '` WHERE parent = v.code GROUP BY parent';
            $data['_children'] = new Expr('@children := COALESCE((' . $select1 . '), (' . $select2 . '))');
            $data['sku'] = 'v.code'; // TODO
            $data['url_key'] = 'v.code'; // TODO
            $firstChildrenSKUExpr = 'substring_index(@children, ",", 1)';
            $data['family'] = new Expr('(SELECT family FROM `tmp_pimgento_entities_product` WHERE sku = ' . $firstChildrenSKUExpr . ' LIMIT 1)');
            $data['_status'] = new Expr('(SELECT _status FROM `tmp_pimgento_entities_product` WHERE sku = ' . $firstChildrenSKUExpr . ' LIMIT 1)');
            $data['categories'] = 'v.categories';

            $configurable = $connection->select()
                ->from(array('v' => $pimgentoVariantTable), $data)
                ->where('v.' . $groupColumn . ' = ""')
                ->group('v.code')
                ->having('_children IS NOT NULL');

It was the problem to collect "family" and "_status" by getting the first SKU from calculated "_children" column and because I use variable "@children" and two additional subselects instead of JOIN.

I also noticed the problem that we create url_key from v.code that is very bad because the configurable product will be public product and for SEO is required correct URL.

I also dislike the current solution that for every configurable product attribute you need to specify it in the Magento Configuration (CONFIG_PIMGENTO_PRODUCT_CONFIGURABLE_ATTR). Would be nice to collect them automatically because in our case we have > 100 attributes and different for each attribute set. So, something can be missed.

@akosglue
Copy link

For your comment about the url_key: this might be relevant: #132

@nicobatty
Copy link

I had the same issue and made a simple fix for this on my fork.

nicobatty@3b765f7

The idea here is to only take the last axis if the parent is not empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants