예제 #1
0
 public function importQuoteItem(Mage_Sales_Model_Quote_Item $quoteItem)
 {
     $this->setQuoteItemId($quoteItem->getId())->setProductId($quoteItem->getProductId())->setProduct($quoteItem->getProduct())->setSuperProductId($quoteItem->getSuperProductId())->setSuperProduct($quoteItem->getSuperProduct())->setSku($quoteItem->getSku())->setImage($quoteItem->getImage())->setName($quoteItem->getName())->setDescription($quoteItem->getDescription())->setWeight($quoteItem->getWeight())->setPrice($quoteItem->getPrice())->setCost($quoteItem->getCost());
     if (!$this->hasQty()) {
         $this->setQty($quoteItem->getQty());
     }
     $this->setQuoteItemImported(true);
     return $this;
 }
 /**
  * Deal with the unavailable item. Mark the item as either out of stock
  * or unavailable in the requested quantity. If the item has not already
  * been added to cart, prevent it from being added.
  *
  * @param Mage_Sales_Model_Quote_Item
  * @param int
  * @return self
  * @throws EbayEnterprise_Inventory_Exception_Quantity_Unavailable If item should not be added to the quote
  */
 public function handleUnavailableItem(Mage_Sales_Model_Quote_Item $item, $quantityAvailable)
 {
     // Unavailable handler assumes that if an item is unavailable, it is
     // a manage stock and non-backorderable item (non-manage stock and
     // backorderable items will never be unavailable).
     $itemIsOutOfStock = $quantityAvailable === 0;
     // Items not already in the cart should not be added if unavailable.
     // Items without an id have not yet been saved and can not have been
     // added to the quote previously. Any item with an id, would have been
     // saved when initially added to the cart previously.
     if (!$item->getId()) {
         $message = $itemIsOutOfStock ? EbayEnterprise_Inventory_Model_Quantity_Service::OUT_OF_STOCK_EXCEPTION_MESSAGE : EbayEnterprise_Inventory_Model_Quantity_Service::INSUFFICIENT_STOCK_EXCEPTION_MESSAGE;
         throw Mage::exception('EbayEnterprise_Inventory_Exception_Quantity_Unavailable', $this->inventoryHelper->__($message, $item->getName(), $quantityAvailable));
     }
     return $itemIsOutOfStock ? $this->_addOutOutOfStockErrorInfo($item) : $this->_addInsufficientStockErrorInfoForItem($item, $quantityAvailable);
 }
예제 #3
0
 /**
  * @param Mage_Sales_Model_Quote_Item $recQuoteItem
  * @return mixed
  */
 public function getRecurringItemMessage(Mage_Sales_Model_Quote_Item $recQuoteItem)
 {
     $recurringItemMessage = '';
     $initialFeeMessage = '';
     $rowTotal = $recQuoteItem->getNominalRowTotal();
     $currency_symbol = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
     $product = $recQuoteItem->getProduct();
     $productAdditionalInfo = unserialize($product->getCustomOption('info_buyRequest')->getValue());
     $deferredDateStamp = strtotime($productAdditionalInfo['recurring_profile_start_datetime']);
     if ($deferredDateStamp) {
         $initialFeeMessage = $this->__(" (initial fee only, 1st recurring fee will be charged on %s)", date('d-M-Y', $deferredDateStamp));
         $rowTotal = $recQuoteItem->getXpRecurringInitialFee() + $recQuoteItem->getInitialfeeTaxAmount();
     }
     $recurringItemMessage = $this->__("%s%s for recurring product '%s' in your cart.", number_format($rowTotal, 2, '.', ''), $currency_symbol, $recQuoteItem->getName());
     $mainMessage = $recurringItemMessage . $initialFeeMessage;
     return $mainMessage;
 }
예제 #4
0
 /**
  * Returns the name for a quote item.
  * Configurable products will have their chosen options added to their name.
  * Bundle products will have their chosen child product names added.
  * Grouped products will have their parent product name prepended.
  * All others will have their own name only.
  *
  * @param Mage_Sales_Model_Quote_Item $item the quote item model.
  *
  * @return string
  */
 public function getProductName($item)
 {
     $name = $item->getName();
     $optNames = array();
     if ($item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
         /** @var Mage_Catalog_Model_Product_Type_Configurable $model */
         $model = Mage::getModel('catalog/product_type_configurable');
         $parentIds = $model->getParentIdsByChild($item->getProductId());
         // If the product has a configurable parent, we assume we should tag
         // the parent. If there are many parent IDs, we are safer to tag the
         // products own name alone.
         if (count($parentIds) === 1) {
             $attributes = $item->getBuyRequest()->getData('super_attribute');
             if (is_array($attributes)) {
                 foreach ($attributes as $id => $value) {
                     /** @var Mage_Catalog_Model_Resource_Eav_Attribute $attribute */
                     $attribute = Mage::getModel('catalog/resource_eav_attribute')->load($id);
                     $label = $attribute->getSource()->getOptionText($value);
                     if (!empty($label)) {
                         $optNames[] = $label;
                     }
                 }
             }
         }
     } elseif ($item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
         /* @var $helper Mage_Catalog_Helper_Product_Configuration */
         $helper = Mage::helper('catalog/product_configuration');
         foreach ($helper->getConfigurableOptions($item) as $opt) {
             if (isset($opt['value']) && is_string($opt['value'])) {
                 $optNames[] = $opt['value'];
             }
         }
     } elseif ($item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
         $type = $item->getProduct()->getTypeInstance(true);
         $opts = $type->getOrderOptions($item->getProduct());
         if (isset($opts['bundle_options']) && is_array($opts['bundle_options'])) {
             foreach ($opts['bundle_options'] as $opt) {
                 if (isset($opt['value']) && is_array($opt['value'])) {
                     foreach ($opt['value'] as $val) {
                         $qty = '';
                         if (isset($val['qty']) && is_int($val['qty'])) {
                             $qty .= $val['qty'] . ' x ';
                         }
                         if (isset($val['title']) && is_string($val['title'])) {
                             $optNames[] = $qty . $val['title'];
                         }
                     }
                 }
             }
         }
     } elseif ($item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_GROUPED) {
         $config = $item->getBuyRequest()->getData('super_product_config');
         if (isset($config['product_id'])) {
             /** @var Mage_Catalog_Model_Product $parent */
             $parent = Mage::getModel('catalog/product')->load($config['product_id']);
             $parentName = $parent->getName();
             if (!empty($parentName)) {
                 $name = $parentName . ' - ' . $name;
             }
         }
     }
     if (!empty($optNames)) {
         $name .= ' (' . implode(', ', $optNames) . ')';
     }
     return $name;
 }