Help for integrating the Laravel package
Forum rules: Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#5174 by Kevin
30 Nov 2017, 16:32
Hi all,

I'm currently working on the myaccount history page. More concrete, I'm updating the list of orders a user has ordered. Therefore, I'm updating the following view into my ext folder: /client/html/templates/account/history/list-body-default.php

In the list I'm showing:

    Order id
    Order date
    Payment status
    Delivery status
    Link to order detail

So far so good. Next to this info I want to add the order total price. Which is not part of the order object, but its part of the base object. So I want to initiate a base object based on the order id and then call the getPrice() function.. Reading the Aimeos documentation, I found the following page explaining how to initiate an object in the view:

More concrete :

Code: Select all$context = App::make('\Aimeos\Shop\Base\Context')->get(false);
$manager = \Aimeos\MShop\Factory::createManager( $context, 'order' );

But I'm doing something wrong because this is not working.
Who can advise me on this one?

Thanks a lot!

#5180 by aimeos
01 Dec 2017, 10:36
You can't create managers in the view!

Instead, create a decorator for the account/history client which uses the order/base manager to retrieve the data you need:

You can get the data in the decorator using:
Code: Select all$context = $this->getContext();
$manager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' );
$search = $manager->createSearch();
$search->setConditions( $search->compare( '==', 'order.base.customerid', $context->getUserId() ) );
$view->myprojectOrderBaseItems = $manager->searchItems( $search );

Afterwards, you can match both by the base ID in your template.
#5276 by Kevin
20 Dec 2017, 17:31
Hi Aimeos,

Makes sense, thanks!
One questions, where (in what folder) do we need to write decorators?

#5279 by aimeos
20 Dec 2017, 21:48
In ./client/html/src/Client/Html/Common/Decorator/ so it matches the namespace