Supplier Information in Products Detail, Basket and Billing

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
izaquieltome
Posts: 9
Joined: 19 Mar 2019, 06:54

Supplier Information in Products Detail, Basket and Billing

Post by izaquieltome » 19 Mar 2019, 07:00

Dear All,

I am a bloody beginner in extending Aimeos - I am Using Typo3 8.7.22, PHP 7.2.16 and Aimeos 18.10.0.
One of my biggest challanges for now is to get the Supplier-information into the Product's Detail Pages.
In our Shop-System, we only have one Supplier per Product, so there is always just a 1:1 Relation in theory.
Now I would need to get the Image of the supplier into the Product's Detail Page, so a Customer can see, where the product is manufactured, and the Code into the Basket and the order.

I Tried it with following Code in the Products "body-standard" Template, but I always get an Error:

Code: Select all

$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'supplier' );

    $search = $manager->createSearch( true );
    $expr = array(
        $search->compare( '==', 'supplier.lists.refid', $product->getProductId() ),
        $search->compare( '==', 'supplier.lists.domain', 'product' ),
        $search->getConditions(),
    );
    $search->setConditions( $search->combine( '&&', $expr ) );

    print_r( $manager->searchItems(  $search ) );
The Error is as follows:

Oops, an error occurred!
Class "\Aimeos\MW\View\Helper\GetContext\Standard" not available

I always read something about putting Codes like this into Controllers, but i really have no idea, which controllers are meant and how i can get it in there.
I hope, someone can help me on that.

Best regards and Thank you,

Izaquiel

boettner
Advanced
Posts: 136
Joined: 09 Feb 2015, 17:49

Re: Supplier Information in Products Detail, Basket and Bill

Post by boettner » 19 Mar 2019, 07:21

Hi Izaquiel,

you need to put this kind of logic into a Decorator and send your query result as a view variable like explained here:
https://aimeos.org/docs/Developers/Html ... components

Best
Robert.

izaquieltome
Posts: 9
Joined: 19 Mar 2019, 06:54

Re: Supplier Information in Products Detail, Basket and Bill

Post by izaquieltome » 19 Mar 2019, 08:23

Hello Robert,

thx for that quick support.
So, know i got the Decorator integrated and recognized by my Template.

But i can'T figure out, how I can access the Data. Maybe you can Help me with that?

Thanks and best Regards,
Izaquiel

boettner
Advanced
Posts: 136
Joined: 09 Feb 2015, 17:49

Re: Supplier Information in Products Detail, Basket and Bill

Post by boettner » 19 Mar 2019, 08:28

You are welcome!

you have to assign your variables or query results to the view like so:

Code: Select all

$view->myQueryresult = $manager->searchItems(  $search )
In your template the variable is available as $myQueryresult afterwards. Also be aware when using partials to hand them over from the parent template to the partial as they aren´t available publicly by default.

izaquieltome
Posts: 9
Joined: 19 Mar 2019, 06:54

Re: Supplier Information in Products Detail, Basket and Bill

Post by izaquieltome » 19 Mar 2019, 08:43

Ok, thank you - seams to work "a little bit".

So, if i comment out the PArts, wehre i search for the Product ID relation, i get a "NULL", when i var_dump the $myQueryresult Variable.
When i use those 2 lines of Code, i get the Error
Oops, an error occurred!
Call to a member function getProductId() on null

which seems logical to my, but how can i get the Product ID into the Query?

Thx again :)

boettner
Advanced
Posts: 136
Joined: 09 Feb 2015, 17:49

Re: Supplier Information in Products Detail, Basket and Bill

Post by boettner » 19 Mar 2019, 08:50

The id should be available here:

Code: Select all

$prodid = $view->param( 'd_prodid' );
If you are in search for what is available in the Client you are working on it may help to look into the Client class you are writing your decorator for:
typo3conf/ext/aimeos/Resources/Private/Extensions/ai-client-html/client/html/src/Client/Html/Catalog/Detail/Standard.php

izaquieltome
Posts: 9
Joined: 19 Mar 2019, 06:54

Re: Supplier Information in Products Detail, Basket and Bill

Post by izaquieltome » 19 Mar 2019, 10:12

Big, big thanks ... it's works :)

boettner
Advanced
Posts: 136
Joined: 09 Feb 2015, 17:49

Re: Supplier Information in Products Detail, Basket and Bill

Post by boettner » 19 Mar 2019, 10:27

Great, nice to hear. :)

izaquieltome
Posts: 9
Joined: 19 Mar 2019, 06:54

Re: Supplier Information in Products Detail, Basket and Bill

Post by izaquieltome » 28 Mar 2019, 05:07

Ok - so i am standing at the next point:
The Basket. There is, as i saw in a var_dump a field called "suppliercode" for each product, but that is ALWAYS NULL.
So, in my Product Detail Page i got the Supplier Infos as I wanted them. But in Basket (and the Order-Details in Backend for Invoicing) i still need to get the Suppliercode (as it is used as a Reference for the Shop-Owner to it's different branches) into the Output of each Product.

Do I need a Decorator too for this? Or how is the Field "Suppliercode" used here?

Best regards and thanks

boettner
Advanced
Posts: 136
Joined: 09 Feb 2015, 17:49

Re: Supplier Information in Products Detail, Basket and Bill

Post by boettner » 28 Mar 2019, 07:22

Hi Izaquiel,

yes I would suggest a Decroator, at least for digging deeper.

You are looking for properties of:
typo3conf/ext/aimeos/Resources/Libraries/aimeos/aimeos-core/lib/mshoplib/src/MShop/Order/Manager/Base/Product/Standard.php

I would try and place your decorator here to have it available in checkout

Code: Select all

                checkout {
                    standard {
                        decorators {
                            global {
                                0 = Yourdecorator
                            }
                        }
                    }
                }
Try an look what extOrderBaseItem gives you back:

Code: Select all

$view->extOrderBaseItem->toArray();
Didn´t try it myself though.

Cheers
Robert.

Post Reply