Page 1 of 1

How to extend \Aimeos\Controller\Frontend\Service\Standard when dealing with a large amount of delivery options

Posted: 07 Nov 2019, 10:13
by boettner
Hi all,

we have a delivery matrix offering a large granularity of weight steps and national and international delivery destinations. That´s maybe something to be handled by using a service providers API but the customer opted for managing that via CSV import.

In

Code: Select all

\Aimeos\Controller\Frontend\Service\Standard->getProviders()
the search slice is configured with 0, 100 as default, so not all delivery options get respected.

How can I extend that?

Best
Robert.

Re: How to extend \Aimeos\Controller\Frontend\Service\Standard when dealing with a large amount of delivery options

Posted: 07 Nov 2019, 18:51
by aimeos
Can you provide a PR to increase the limit to 10,000?

Re: How to extend \Aimeos\Controller\Frontend\Service\Standard when dealing with a large amount of delivery options

Posted: 10 Nov 2019, 11:52
by aimeos
Maybe it's better to create one service decorator that implements the calcPrice() method and sets the price according to the contents of the file compared to the basket content. If there are multiple types of shipping (parcel, heavy transport), you can create one service decorator for each type which should be only 2-3.

Re: How to extend \Aimeos\Controller\Frontend\Service\Standard when dealing with a large amount of delivery options

Posted: 11 Nov 2019, 10:23
by boettner
Just created the PR but didn´t read your last reply yet. I´m not sure if your last suggestion applies to my post.

Before we had only one valid delivery service per basket depending on weight and destination. Now there´s the choice between standard and express delivery also depending on weight and destination.

Extending the slice already fixed the issue for me.

Thanks!

Re: How to extend \Aimeos\Controller\Frontend\Service\Standard when dealing with a large amount of delivery options

Posted: 11 Nov 2019, 10:38
by aimeos
Yes, but instead of creating hundreds of delivery options, wouldn't it be better to create only two (standard and express) that calculate the shipping costs depending on the content of the CSV file?

Re: How to extend \Aimeos\Controller\Frontend\Service\Standard when dealing with a large amount of delivery options

Posted: 11 Nov 2019, 10:43
by boettner
This would be another approach but why calculating every basket when it´s a static resource? Isn´t it better regarding performance doing it via import? Especially because file access would be involved.

Re: How to extend \Aimeos\Controller\Frontend\Service\Standard when dealing with a large amount of delivery options

Posted: 11 Nov 2019, 10:54
by aimeos
Normally imports are preferable due to performance reasons, but in this case it has no performance advantage - maybe even a performance loss.

You create hundreds of delivery service options and if a customer requests the shipping page in the checkout process, for each shipping option the provider needs to be instantiated and the isAvailable() method called that performs a check depending on the basket content. Calling >100 times isAvailable() and running the same checks again might be slower calling calcPrice() two times evaluating the CSV file (or an indexed table where you store the restrictions for each shipping option for faster lookups).

Re: How to extend \Aimeos\Controller\Frontend\Service\Standard when dealing with a large amount of delivery options

Posted: 11 Nov 2019, 11:03
by boettner
Ok, I will have to sell that to my customer because he´s the one paying my work. From years of experience, explaining deep technical aspects to people in purchasing or marketing will not very likely clear things up for them. Especially when the slice fix already fixed the issue for them. But we will see.

Does that mean that my PR will be rejected?

Re: How to extend \Aimeos\Controller\Frontend\Service\Standard when dealing with a large amount of delivery options

Posted: 12 Nov 2019, 08:59
by aimeos
No PR received yet but it would be better to overwrite the service frontend controller:
https://github.com/aimeos/ai-controller ... hp#L39-L47

Example code:

Code: Select all

namespace Aimeos\Controller\Frontend\Service;

class MyService extends Standard
{
	public function __construct( \Aimeos\MShop\Context\Item\Iface $context )
	{
		parent::__construct( $context );
		$this->setSlice( 0, 1000 );
	}
}
Configuration:

Code: Select all

controller/frontend/service/name = MyService