Determine select article from a default product

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
heural
Posts: 58
Joined: 09 Jun 2022, 07:55

Determine select article from a default product

Post by heural » 17 Apr 2023, 09:23

Hi Aimeos-Team,

is there a "elegant" way to determine the "parent" select article within a default article?

Background:
We add from an external service a default product into the basket. But if is part of a select article (variant) then the basket order line should link to the detail page of the select article instead of the default product detail page.

Thank you !
Ralf

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

Re: Determine select article from a default product

Post by aimeos » 19 Apr 2023, 09:02

To check if an article has one or more parent products (selection or bundle products), you can use these lines of code in a decorator for the basket/standard component:

Code: Select all

$manager = \Aimeos\MShop::create( $this->context(), 'product' );
$filter = $manager->filter();
$filter->add( $filter->make( 'product:has', ['product', 'default', <article ID>] ), '!=', null ) );
if( !$manager->search( $filter )->isEmpty() ) {
	// ...
}
See also:
- Search functions: https://aimeos.org/docs/latest/models/s ... -functions
- Client decorators: https://aimeos.org/docs/latest/frontend ... omponents/
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply