get product attribute in the order plugin

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

get product attribute in the order plugin

Post by ahmed31916 » 08 Jun 2022, 11:18

Hello,

For this plugin code, (when I use addProduct event), how can I get the attribute of the requested product?

Code: Select all

class Example
    extends \Aimeos\MShop\Plugin\Provider\Decorator\Base
    implements \Aimeos\MShop\Plugin\Provider\Decorator\Iface
{
    public function update( \Aimeos\MW\Observer\Publisher\Iface $order, $action, $value = null )
    {
	dd($order->getProducts());
        return true;
    }
}

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

Re: get product attribute in the order plugin

Post by aimeos » 10 Jun 2022, 07:36

Depending on the events your plugin is listening for, the data/object is passed in the $value parameter:

Code: Select all

if( $value ) {
	$attrItems = $value->getAttributeItems();
}
Check the interface for available methods:
https://github.com/aimeos/aimeos-core/b ... #L401-L425
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply