Price data not copied from Product to OrderProduct
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!
Price data not copied from Product to OrderProduct
Hi,
I need to add products to the order/basket item.
Products including medias are added as expected, but the price domain is missing.
'price' is added as data domain to the $product, but missing (not copied) in the $orderProduct
log output:
thank you!
I need to add products to the order/basket item.
Products including medias are added as expected, but the price domain is missing.
Code: Select all
$manager = \Aimeos\MShop::create( $context, 'order/basket' );
$filter = $manager->filter()
->add( 'order.basket.customerid', '==', $context->user() )
->add( 'order.basket.id', '==', $basketid );
$basket = $manager->search( $filter )->first();
if($item = $basket->getItem())
{
$product = \Aimeos\MShop::create($context, 'product')->get( $prodid, ['text', 'media', 'price']);
$orderProduct = \Aimeos\MShop::create($context, 'order/product')->create()->copyFrom($product);
$item->addProduct($orderProduct);
$manager->save($basket->setItem( $item ));
Log::info(print_r($orderProduct, true));
}log output:
Code: Select all
production.INFO: Aimeos\MShop\Order\Item\Product\Standard Object
(
[available:protected] => 1
[modified:protected] => 1
[bprefix:protected] => order.product.
[type:protected] =>
[bdata:protected] => Array
(
[.price] => Aimeos\MShop\Price\Item\Standard Object
(
[available:protected] => 1
[modified:protected] => 1
[bprefix:protected] => price.
[type:protected] =>
[bdata:protected] => Array
(
[.currencyid] => EUR
[price.taxflag] => 1
[price.precision] => 2
[price.currencyid] => EUR
[price.siteid] => 1.
)
[precision:Aimeos\MShop\Price\Item\Standard:private] => 2
[tax:Aimeos\MShop\Price\Item\Standard:private] => 0
[listItems:Aimeos\MShop\Price\Item\Standard:private] => Array
(
)
[listRmItems:Aimeos\MShop\Price\Item\Standard:private] => Array
(
)
[listMap:Aimeos\MShop\Price\Item\Standard:private] => Array
(
)
[listMax:Aimeos\MShop\Price\Item\Standard:private] => 0
[propItems:Aimeos\MShop\Price\Item\Standard:private] => Array
(
)
[propRmItems:Aimeos\MShop\Price\Item\Standard:private] => Array
(
)
[propMax:Aimeos\MShop\Price\Item\Standard:private] => 0
)
[order.product.siteid] => 1.
[order.product.prodcode] => 4567
[order.product.productid] => 123
[order.product.type] => default
[order.product.scale] => 1
[order.product.target] =>
[order.product.name] => My Product
[order.product.mediaurl] => prodimg/My_Product.jpeg
)
[attributesMap:Aimeos\MShop\Order\Item\Product\Base:private] =>
[attrRmItems:Aimeos\MShop\Order\Item\Product\Base:private] => Array
(
)
)Re: Price data not copied from Product to OrderProduct
Price calculation is more complex then just copying the first available price:
- https://github.com/aimeos/ai-controller ... #L347-L359
- https://github.com/aimeos/ai-controller ... se.php#L31
- https://github.com/aimeos/ai-controller ... #L347-L359
- https://github.com/aimeos/ai-controller ... se.php#L31
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,