/** * Creates the order product attribute items from the given attribute IDs and updates the price item if necessary. * * @param \Aimeos\MShop\Price\Item\Iface $price Price item of the ordered product * @param string $prodid Unique product ID where the given attributes must be attached to * @param integer $quantity Number of products that should be added to the basket * @param array $attributeIds List of attributes IDs of the given type * @param string $type Attribute type * @param array $attributeValues Associative list of attribute IDs as keys and their codes as values * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface */ protected function createOrderProductAttributes(\Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, array $attributeIds, $type, array $attributeValues = array()) { if (empty($attributeIds)) { return array(); } $attrTypeId = $this->getProductListTypeItem('attribute', $type)->getId(); $this->checkReferences($prodid, 'attribute', $attrTypeId, $attributeIds); $list = array(); $context = $this->getContext(); $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product/attribute'); foreach ($this->getAttributes($attributeIds) as $id => $attrItem) { $prices = $attrItem->getRefItems('price', 'default', 'default'); if (!empty($prices)) { $price->addItem($priceManager->getLowestPrice($prices, $quantity)); } $item = $orderProductAttributeManager->createItem(); $item->copyFrom($attrItem); $item->setType($type); if (isset($attributeValues[$id])) { $item->setValue($attributeValues[$id]); } $list[] = $item; } return $list; }