Price rules don't work when using product manager
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!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
- VadimSaratov
- Posts: 8
- Joined: 09 May 2022, 15:27
Price rules don't work when using product manager
I am using aimeos laravel 2021.10.5 and laravel 8.42.1 I created price rules as described in the documentation https://aimeos.org/docs/2021.x/providers/rules/ and the rules work for the JSON API, when displayed in the store, etc. but when I request a product with a price using the manager, the rules do not apply to the price.
should the price rules be applied automatically when requesting through the manager, or should I apply the decorator manually in this case?
my code using manager looks like this:
should the price rules be applied automatically when requesting through the manager, or should I apply the decorator manually in this case?
my code using manager looks like this:
Code: Select all
$manager = MShop::create(app('aimeos.context')->get(), 'product');
$product = $manager->get($product_id,
[
'attribute',
'media',
'price',
'product',
'product/property',
'text',
'catalog',
'supplier',
'stock'
]
Re: Price rules don't work when using product manager
Price rules are only applied to the frontend, otherwise managing product prices would not be possible. Use the frontend controller instead, which applies the price rules automatically:
https://github.com/aimeos/ai-controller ... d.php#L202
An equivalent example is:
For the available methods, have alook into the interface:
https://github.com/aimeos/ai-controller ... /Iface.php
https://github.com/aimeos/ai-controller ... d.php#L202
An equivalent example is:
Code: Select all
\Aimeos\Controller\Frontend::create(app('aimeos.context')->get(), 'product')
->uses( [
'attribute',
'media',
'price',
'product',
'product/property',
'text',
'catalog',
'supplier',
'stock'
] )
->get( $product_id );
https://github.com/aimeos/ai-controller ... /Iface.php
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
- VadimSaratov
- Posts: 8
- Joined: 09 May 2022, 15:27