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

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!
boettner
Advanced
Posts: 136
Joined: 09 Feb 2015, 17:49

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

Post by boettner » 07 Nov 2019, 10:13

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.

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

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

Post by aimeos » 07 Nov 2019, 18:51

Can you provide a PR to increase the limit to 10,000?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

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

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

Post by aimeos » 10 Nov 2019, 11:52

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.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

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

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

Post by boettner » 11 Nov 2019, 10:23

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!

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

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

Post by aimeos » 11 Nov 2019, 10:38

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?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

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

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

Post by boettner » 11 Nov 2019, 10:43

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.

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

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

Post by aimeos » 11 Nov 2019, 10:54

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).
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

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

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

Post by boettner » 11 Nov 2019, 11:03

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?

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

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

Post by aimeos » 12 Nov 2019, 08:59

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
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply