variant attributes for selection not displayed on FE

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

variant attributes for selection not displayed on FE

Post by MikaelNazarenko » 17 Jan 2022, 13:32

Hi Aimeos )

When I add variant attributes to selection product - they not displayed on FE inside single product page.. Is it correct behavior ?

User avatar
aimeos
Administrator
Posts: 7889
Joined: 01 Jan 1970, 00:00

Re: variant attributes for selection not displayed on FE

Post by aimeos » 18 Jan 2022, 09:14

Can you post screenshots?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: variant attributes for selection not displayed on FE

Post by MikaelNazarenko » 18 Jan 2022, 10:32

Sure,

Here you see attributes for variants https://prnt.sc/26f439e

And they are displayed on FE https://prnt.sc/26f43s6

And here you see variant attributes for main selection product https://prnt.sc/26f449p

And pink color not shown on FE, only colors from variants are displayed.. The template code I did not change, only css.

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: variant attributes for selection not displayed on FE

Post by MikaelNazarenko » 18 Jan 2022, 10:35

My target is something like this: I want to have 2 variants of product. So I want to create selection product and 1 variant product. Then I assign variant attributes for selection and for variant. Then when I go inside product on FE the attributes should be preselected as for selection product, or possible to select attributes from variant... Should it work like this ?

Thank you a lot !

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: variant attributes for selection not displayed on FE

Post by MikaelNazarenko » 18 Jan 2022, 10:47

From what I see here ext/ai-client-html/client/html/templates/common/partials/selection-standard.php variant attributes from selection product not used..

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: variant attributes for selection not displayed on FE

Post by MikaelNazarenko » 18 Jan 2022, 10:59

Seems such a code is missing in the file I specified above:

Code: Select all

foreach ($this->get('productItem')->getRefItems( 'attribute', null, 'variant' ) as $attrId => $attrItem) {
    $attrTypeDeps[$attrItem->getType()][$attrId] = $attrItem->getPosition();
    $attributeItems[$attrId] = $attrItem;
    $attrDeps[$attrId][] = $this->get('productItem')->getId();
    $prodDeps[$this->get('productItem')->getId()][] = $attrId;
}
with this code from first look it should work..

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: variant attributes for selection not displayed on FE

Post by MikaelNazarenko » 18 Jan 2022, 11:08

but now when I choose var attributes from selection product - product is not added to basked. When I choose var attributes from variant product - product is added to basked.. Seems missed something

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: variant attributes for selection not displayed on FE

Post by MikaelNazarenko » 18 Jan 2022, 12:15

I did not check deep but seems after adding the following code:

Code: Select all

$isSelectionAttrSelected = true;
foreach( $variant as $id )
{
            if( $productItem->getListItem( 'attribute', 'variant', $id ) === null ) {
                $isSelectionAttrSelected = false;
                break;
            }
}
if($isSelectionAttrSelected) {
            $items[] = $productItem;
}
before the line:

Code: Select all

foreach( $productItem->getRefItems( 'product', null, 'default' ) as $item )
method getArticle()

in the file /vendor/aimeos/ai-controller-frontend/controller/frontend/src/Controller/Frontend/Basket/Decorator/Select.php

it works. I mean when I select variant attributes from selection product - the product added to basked with correct attributes!

Please look at the code I provided and tell me if it is right solution ?

Thank you !

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: variant attributes for selection not displayed on FE

Post by MikaelNazarenko » 18 Jan 2022, 12:20

Sorry forgot specify the components version:

Code: Select all

aimeos/ai-admin-jqadm              2021.10.4 Aimeos Vue.js+Bootstrap admin interface
aimeos/ai-admin-jsonadm            2021.10.2 Aimeos ai-admin-jsonadm extension
aimeos/ai-client-html              2021.10.5 Aimeos ai-client-html extension
aimeos/ai-client-jsonapi           2021.10.2 Aimeos JSON API extension
aimeos/ai-cms-grapesjs             2021.10.1 Aimeos GrapesJS CMS extension
aimeos/ai-controller-frontend      2021.10.2 Aimeos ai-controller-frontend extension
aimeos/ai-controller-jobs          2021.10.3 Aimeos ai-controller-jobs extension
aimeos/ai-gettext                  2021.10.1 Aimeos Gettext extension
aimeos/ai-laravel                  2021.10.1 Laravel adapter for Aimeos web shops and e-commerce solutions
aimeos/ai-swiftmailer              2021.10.1 SwiftMailer adapter for Aimeos web shops and e-commerce solutions
aimeos/aimeos-core                 2021.10.6 Full-featured e-commerce components for high performance online shops
aimeos/aimeos-laravel              2021.10.3 Professional, full-featured and high performance Laravel e-commerce package for online shops and complex B2B projects
aimeos/map                         2.4.0     Easy and elegant handling of PHP arrays as array-like map objects similar to jQuery and Laravel Collections

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: variant attributes for selection not displayed on FE

Post by MikaelNazarenko » 18 Jan 2022, 12:44

I don't understand now how to extend /vendor/aimeos/ai-controller-frontend/controller/frontend/src/Controller/Frontend/Basket/Decorator/Select.php this decorator

Post Reply