Page 1 of 1

Object initiation

Posted: 30 Nov 2017, 16:32
by Kevin
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: https://aimeos.org/docs/Laravel/Extend_Aimeos

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!

Regards,
Kevin

Re: Object initiation

Posted: 01 Dec 2017, 10:36
by aimeos
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: https://aimeos.org/docs/index.php?title ... ldid=50181

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.

Re: Object initiation

Posted: 20 Dec 2017, 17:31
by Kevin
Hi Aimeos,

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

K.

Re: Object initiation

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