Beispiel #1
0
 /**
  * Returns the sku of the given item dependant on the product type.
  *
  * @param Mage_Sales_Model_Order_Item $item The item to return info from
  * @return String The sku
  */
 protected function getItemSku($item)
 {
     if ($item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
         return $item->getProductOptionByCode('simple_sku');
     }
     return $item->getSku();
 }
 /**
  * get allocation information for an item
  *
  * @param  Mage_Sales_Model_Order_Item
  * @return EbayEnterprise_Inventory_Model_Allocation|null
  */
 public function getItemAllocationInformation(Mage_Sales_Model_Order_Item $item)
 {
     $result = $this->getInventorySession()->getAllocationResult();
     if ($result) {
         return $result->lookupAllocationByItemId($item->getQuoteItemId());
     }
     $this->logger->debug('Unable to get allocation information for item {sku} id {item_id}', $this->logContext->getMetaData(__CLASS__, ['sku' => $item->getSku(), 'item_id' => $item->getQuoteItemId()]));
     return null;
 }
 /**
  * check if the current sku already exists in the params data if so return
  * the position it is found in
  * @param array $params the given array of keys needed to build the beacon URL querystring
  * @param Mage_Sales_Model_Order_Item $item
  * @return int the item position where dupe found otherwise zero
  */
 protected function _getDupePosition(array $params, Mage_Sales_Model_Order_Item $item)
 {
     $key = array_search($item->getSku(), $params, true);
     return $key !== false ? (int) str_replace(static::KEY_ITEM, '', $key) : 0;
 }
Beispiel #4
0
 /**
  * Retrieves RMA item sku for backend
  *
  * @param  Mage_Sales_Model_Order_Item $item
  * @return string
  */
 public function getAdminProductSku($item)
 {
     $name = $item->getSku();
     if ($item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
         $productOptions = $item->getProductOptions();
         return $productOptions['simple_sku'];
     }
     return $name;
 }
 /**
  * handle the case where there is not enough stock to allocate the
  * full amount requested
  *
  * @param EbayEnterprise_Inventory_Model_Allocation
  * @param Mage_Sales_Model_Order_Item
  * @throws EbayEnterprise_Inventory_Exception_Allocation_Availability_Exception
  */
 protected function handleInsufficientStock(Mage_Sales_Model_Order_Item $item)
 {
     $this->logger->debug('Unable to reserve desired quantity for item {sku}', $this->logContext->getMetaData(__CLASS__, ['sku' => $item->getSku()]));
     throw Mage::exception('EbayEnterprise_Inventory_Exception_Allocation_Availability', $this->invHelper->__(static::INSUFFICIENT_STOCK_MESSAGE));
 }
Beispiel #6
0
 /**
  * Retrieve
  *
  * @param Mage_Sales_Model_Order_Item $item
  * @return unknown
  */
 public function itemToQuoteItem(Mage_Sales_Model_Order_Item $item)
 {
     $quoteItem = Mage::getModel('sales/quote_item')->setStoreId($item->getStoreId())->setQuoteItemId($item->getId())->setProductId($item->getProductId())->setSuperProductId($item->getSuperProductId())->setParentProductId($item->getParentProductId())->setSku($item->getSku())->setName($item->getName())->setDescription($item->getDescription())->setWeight($item->getWeight())->setCustomPrice($item->getPrice())->setDiscountPercent($item->getDiscountPercent())->setDiscountAmount($item->getDiscountAmount())->setTaxPercent($item->getTaxPercent())->setTaxAmount($item->getTaxAmount())->setRowWeight($item->getRowWeight())->setRowTotal($item->getRowTotal())->setAppliedRuleIds($item->getAppliedRuleIds())->setBaseDiscountAmount($item->getBaseDiscountAmount())->setBaseTaxAmount($item->getBaseTaxAmount())->setBaseRowTotal($item->getBaseRowTotal());
     return $quoteItem;
 }
Beispiel #7
0
 /**
  * Returns SimpleOrderLineData record
  *
  * @param Mage_Sales_Model_Order_Item $item
  * @return array
  */
 protected function _createSimpleOrderLineData(Mage_Sales_Model_Order_Item $item)
 {
     /** @var $product Mage_Catalog_Model_Product */
     $product = Mage::getModel('catalog/product')->setStoreId($item->getStoreId())->load($item->getProductId());
     $data = array('orderLineId' => null, 'itemId' => (string) $item->getId(), 'orderNumber' => (string) $this->getOrderNumber(), 'quantity' => (double) $item->getQtyOrdered(), 'productSku' => (string) $item->getSku(), 'itemDescription' => (string) ($product->getShortDescription() ? $product->getShortDescription() : $product->getDescription()), 'unitPrice' => $this->_createOrderLinePrice($item, $item->getQtyOrdered()), 'totalTaxAmount' => $this->_createCurrencyAmount($item->getTaxAmount()), 'status' => $this->_createOrderItemStatus($item), 'price' => $this->_createCurrencyAmount($item->getBaseRowTotal()), 'allDiscounts' => null, 'dateCancelled' => null, 'dateDelivered' => null, 'dateShipped' => null, 'dateReturned' => null, 'dateInvoiced' => null, 'destination' => $this->_createShipTo($item->getOrder()->getShippingAddress()), 'shipmentId' => null, 'offerId' => null, 'offerUrl' => null);
     return $data;
 }
 /**
  * Get the product the item represents.
  *
  * @param Mage_Sales_Model_Order_Item
  * @return Mage_Catalog_Model_Product
  */
 protected function getItemProduct(Mage_Sales_Model_Order_Item $item)
 {
     // When dealing with configurable items, need to get tax data from
     // the child product and not the parent.
     if ($item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
         $sku = $item->getSku();
         $children = $item->getChildrenItems();
         if ($children) {
             /** @var Mage_Sales_Model_Order_Item $childItem */
             foreach ($children as $childItem) {
                 $childProduct = $childItem->getProduct();
                 // If the SKU of the child product matches the SKU of the
                 // item, the simple product being ordered was found and should
                 // be used.
                 if ($childProduct->getSku() === $sku) {
                     return $childProduct;
                 }
             }
         }
     }
     return $item->getProduct() ?: Mage::getModel('catalog/product')->load($item->getProductId());
 }
Beispiel #9
0
 /**
  * array_reduce callback to get comma separated list of product ids
  * @param string $result
  * @param Mage_Sales_Model_Quote_Item|Mage_Sales_Model_Order_Item $item
  * @return string
  */
 protected function _pidListFromCollection($result, $item)
 {
     $productId = $item->getSku();
     $result .= (empty($result) ? '' : ',') . $productId;
     return $result;
 }
 private function _scheduleSerialAssignment(Mage_Sales_Model_Order_Item $orderItem)
 {
     $queueItem = $this->getInfo('queue_item');
     if ($queueItem instanceof Gorilla_Queue_Model_Queue && $queueItem->getId()) {
         try {
             $queueItem->update();
             return true;
         } catch (Exception $e) {
             $ecodesException = new ICC_Ecodes_Exception($e->getMessage(), $e->getCode(), $e->getPrevious());
             Mage::logException($ecodesException);
             $this->addError('There was an error registering with the Queue. Some eCodes may not recieve serial assignments.');
             return false;
         }
     } else {
         try {
             Mage::getModel('gorilla_queue/queue')->addToQueue('ecodes/observer', 'assignSerialsFromQueue', array('order_item_id' => $orderItem->getId(), 'sku' => $orderItem->getSku(), 'gp_sku' => $this->getGpSkuFromProductId($orderItem->getProductId())), 'ecodes-assign-serials')->setShortDescription('Order Item ' . $orderItem->getId() . ' needs a serial. [' . $orderItem->getName() . ']')->save();
             return true;
         } catch (Exception $e) {
             $ecodesException = new ICC_Ecodes_Exception($e->getMessage(), $e->getCode(), $e->getPrevious());
             Mage::logException($ecodesException);
             $this->addError('There was an error registering with the Queue. Some eCodes may not recieve serial assignments.');
             return false;
         }
     }
 }
 /**
  * Encodes an individual order item.
  *
  * @param array                       $mapping
  * @param Mage_Sales_Model_Order_Item $item
  *
  * @return \SixBySix\RealtimeDespatch\Entity\OrderLine
  */
 protected function _encodeOrderItem($mapping, Mage_Sales_Model_Order_Item $item)
 {
     $orderFlowLine = new RTDOrderLine();
     foreach ($mapping->asArray() as $magentoKey => $rtdKey) {
         $orderFlowLine->setParam($rtdKey, $item->{'get' . $magentoKey}());
     }
     $orderFlowLine->setProduct(new RTDProduct($item->getSku()));
     return $orderFlowLine;
 }