Determine select article from a default product
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!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Determine select article from a default product
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
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
Re: Determine select article from a default product
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:
See also:
- Search functions: https://aimeos.org/docs/latest/models/s ... -functions
- Client decorators: https://aimeos.org/docs/latest/frontend ... omponents/
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() ) {
// ...
}
- 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, give us a star
If you like Aimeos, give us a star