Include the store details with each order

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!
User avatar
ahmed31916
Advanced
Posts: 148
Joined: 14 Apr 2022, 12:15

Include the store details with each order

Post by ahmed31916 » 14 Aug 2022, 19:09

Hello Aimeos,

1. How can I get the store details for each order, in the history template? it shows just the Label of the store

2. How to get product url ('order.base.product.url') in the basket template or any checkout steps? it must be exist

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

Re: Include the store details with each order

Post by aimeos » 16 Aug 2022, 06:58

ahmed31916 wrote: 14 Aug 2022, 19:09 1. How can I get the store details for each order, in the history template? it shows just the Label of the store
If you overwrite the account/history component class and change data() like this:

Code: Select all

	public function data( \Aimeos\Base\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\Base\View\Iface
	{
		$view->historyItems = \Aimeos\Controller\Frontend::create( $this->context(), 'order' )
			->uses( ['product', 'locale/site', 'order/base', 'order/base/address', 'order/base/coupon', 'order/base/product', 'order/base/service'] )
			->sort( '-order.id' )
			->search();

		return parent::data( $view, $tags, $expire );
	}
This fetches the original products including the site items for each product, so you can use in the template:

Code: Select all

$orderProduct->getProductItem()->getSiteItem()
See: https://github.com/aimeos/ai-client-htm ... rd.php#L69

We will make that configurable so it's simply a config setting in the future.
ahmed31916 wrote: 14 Aug 2022, 19:09 2. How to get product url ('order.base.product.url') in the basket template or any checkout steps? it must be exist
You can create a decorator that fetches the original product for basket and checkout views. The original product is the only place where the URL segment is available.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

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

Re: Include the store details with each order

Post by aimeos » 20 Aug 2022, 09:52

You can create a decorator which loops over the products in the basket you can get from the view and fetch the site items for the site IDs of the products:

Code: Select all

$siteIds = $view->standardBasket->getProducts()->getSiteId();
$manager = \Aimeos\MShop::create( $this->context(), 'locale/site' );
$siteItems = $manager->search( $manager->filter()->add( ['locale.site.siteid' => $siteIds] ) );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply