/** * Migrates the products from the old basket to the current one. * * @param MShop_Order_Item_Base_Interface $basket Basket object * @param array $errors Associative list of previous errors * @param string $localeKey Unique identifier of the site, language and currency * @return array Associative list of errors occured */ private function _copyProducts(MShop_Order_Item_Base_Interface $basket, array $errors, $localeKey) { foreach ($basket->getProducts() as $pos => $product) { if ($product->getFlags() & MShop_Order_Item_Base_Product_Abstract::FLAG_IMMUTABLE) { continue; } try { $attrIds = array(); foreach ($product->getAttributes() as $attrItem) { $attrIds[$attrItem->getType()][] = $attrItem->getAttributeId(); } $this->addProduct($product->getProductId(), $product->getQuantity(), array(), $this->_getValue($attrIds, 'variant', array()), $this->_getValue($attrIds, 'config', array()), $this->_getValue($attrIds, 'hidden', array()), $this->_getValue($attrIds, 'custom', array()), $product->getWarehouseCode()); $basket->deleteProduct($pos); } catch (Exception $e) { $code = $product->getProductCode(); $logger = $this->_getContext()->getLogger(); $str = 'Error migrating product with code "%1$s" in basket to locale "%2$s": %3$s'; $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), MW_Logger_Abstract::INFO); $errors['product'][$pos] = $e->getMessage(); } } return $errors; }