Closed exemplari closed 3 years ago
So i ended up with the final if attribute to try and find the product supplier code. $product->getSupplierCode() but that value is empty i double checked that the product does have a supplier code assigned Some issue with the manager / item ?
even when i complete an order the mshop_order_base_product does not have the appropriate suppliercode in mshop_order_base_product
not sure if the supplier code issues isnt better solved in the item, manager. This seems to get by for the meantime.
/**
* Checks for requirements.
*
* @param \Aimeos\MShop\Order\Item\Base\Iface $base Basic order of the customer
* @return bool True if the requirements are met, false if not
*/
public function isAvailable( \Aimeos\MShop\Order\Item\Base\Iface $base ) : bool
{
$supplier = $this->getConfigValue( 'supplier.code' );
$context = $this->getContext();
$manager = \Aimeos\MShop::create($context, 'supplier');
if( $supplier )
{
foreach( $base->getProducts() as $product )
{
$filter = $manager->filter( true );
$filter->add($filter->make('supplier:has', ['product', 'default', $product->getProductId()] ), '!=', null );
$suppliers = $manager->search( $filter );
foreach( $suppliers as $sply) {
if( $sply->getCode() === $supplier ) {
return parent::isAvailable( $base );
}
}
}
}
return false;
}
The coupon supplier decorator limits coupons according to the supplier chosen for Click&Collect delivery option. You want to limit the coupon to the products from one supplier which is a different thing and for that, you have to create you own coupon decorator.
I should have read that better. Thanks
Environment "aimeos/aimeos-laravel": "~2020.10" linux
Describe the bug namespace Aimeos\MShop\Coupon\Provider\Decorator; does not work
To Reproduce Steps to reproduce the behavior:
Expected behavior Basket coupon applies to products with the supplier code
Screenshots If applicable, add screenshots to help explain your problem.
Additional context
It was checking the baseOrder->services instead of the baseOrder->products
namespace Aimeos\MShop\Coupon\Provider\Decorator;