当前位置: 首页>>代码示例>>PHP>>正文


PHP OrderItem::getAllByCriteria方法代码示例

本文整理汇总了PHP中OrderItem::getAllByCriteria方法的典型用法代码示例。如果您正苦于以下问题:PHP OrderItem::getAllByCriteria方法的具体用法?PHP OrderItem::getAllByCriteria怎么用?PHP OrderItem::getAllByCriteria使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OrderItem的用法示例。


在下文中一共展示了OrderItem::getAllByCriteria方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getLatestETAs

 public function getLatestETAs($sender, $param)
 {
     $result = $error = array();
     try {
         $pageNo = $this->pageNumber;
         $pageSize = $this->pageSize;
         if (isset($param->CallbackParameter->pagination)) {
             $pageNo = $param->CallbackParameter->pagination->pageNo;
             $pageSize = $param->CallbackParameter->pagination->pageSize;
         }
         $notSearchStatusIds = array(OrderStatus::ID_CANCELLED, OrderStatus::ID_PICKED, OrderStatus::ID_SHIPPED);
         OrderItem::getQuery()->eagerLoad('OrderItem.order', 'inner join', 'ord', 'ord.id = ord_item.orderId and ord.active = 1');
         $stats = array();
         $oiArray = OrderItem::getAllByCriteria("(eta != '' and eta IS NOT NULL and eta != ? and ord.statusId not in (" . implode(',', $notSearchStatusIds) . "))", array(trim(UDate::zeroDate())), true, $pageNo, $pageSize, array("ord_item.eta" => "ASC", "ord_item.orderId" => "DESC"), $stats);
         $result['pagination'] = $stats;
         $result['items'] = array();
         foreach ($oiArray as $oi) {
             if (!$oi->getProduct() instanceof product) {
                 continue;
             }
             $tmp['eta'] = trim($oi->getEta());
             $tmp['orderNo'] = $oi->getOrder()->getOrderNo();
             $tmp['sku'] = $oi->getProduct() instanceof Product ? $oi->getProduct()->getSku() : '';
             $tmp['productName'] = $oi->getProduct()->getName();
             $tmp['id'] = $oi->getId();
             $tmp['orderId'] = $oi->getOrder()->getId();
             $result['items'][] = $tmp;
         }
     } catch (Exception $ex) {
         $error[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($result, $error);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:33,代码来源:LatestETAPanel.php

示例2: _getInsufficientStockOrders

 private function _getInsufficientStockOrders($params)
 {
     $pageNo = isset($params['pageNo']) ? trim($params['pageNo']) : 1;
     $pageSize = isset($params['pageSize']) ? trim($params['pageSize']) : DaoQuery::DEFAUTL_PAGE_SIZE;
     $sql = "select distinct pro.id, sum(ord_item.qtyOrdered) `orderedQty`, pro.stockOnHand, pro.stockOnPO\r\n  \t\t\t\tfrom product pro\r\n  \t\t\t\tinner join orderitem ord_item on (ord_item.productId = pro.id and ord_item.active = 1)\r\n  \t\t\t\tinner join `order` ord on (ord.id = ord_item.orderId and ord.active = 1 and ord.type in (:ordType1, :ordType2) and ord.statusId in (:ordStatusId1, :ordStatusId2))\r\n  \t\t\t\twhere pro.active = 1\r\n  \t\t\t\tgroup by pro.id\r\n  \t\t\t\thaving `orderedQty` > (pro.stockOnHand + pro.stockOnPO)\r\n  \t\t\t\torder by ord.id";
     $result = Dao::getResultsNative($sql, array('ordType1' => Order::TYPE_ORDER, 'ordType2' => Order::TYPE_INVOICE, 'ordStatusId1' => OrderStatus::ID_NEW, 'ordStatusId2' => OrderStatus::ID_INSUFFICIENT_STOCK), PDO::FETCH_ASSOC);
     if (count($result) === 0) {
         return array();
     }
     $productMap = array();
     foreach ($result as $row) {
         $productMap[$row['id']] = $row;
     }
     OrderItem::getQuery()->eagerLoad('OrderItem.order', 'inner join', 'ord', 'ord.id = ord_item.orderId and ord.active = 1 and ord.type in (?,?) and ord.statusId in (?,?)');
     $sqlParams = array(Order::TYPE_ORDER, Order::TYPE_INVOICE, OrderStatus::ID_NEW, OrderStatus::ID_INSUFFICIENT_STOCK);
     $where = 'ord_item.active = 1 and ord_item.productId in (' . implode(', ', array_fill(0, count(array_keys($productMap)), '?')) . ')';
     $sqlParams = array_merge($sqlParams, array_keys($productMap));
     $items = OrderItem::getAllByCriteria($where, $sqlParams, true, $pageNo, $pageSize, array('ord_item.id' => 'desc'));
     $return = array();
     foreach ($items as $item) {
         $extra = array('totalOrderedQty' => isset($productMap[$item->getProduct()->getId()]) ? $productMap[$item->getProduct()->getId()]['orderedQty'] : 0);
         $return[] = $item->getJson($extra);
     }
     return array('items' => $return);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:25,代码来源:AjaxController.php

示例3: getOrderItems

 /**
  * Getting the orders
  * 
  * @param unknown $sender
  * @param unknown $param
  * @throws Exception
  * 
  */
 public function getOrderItems($sender, $param)
 {
     $results = $errors = array();
     try {
         if (!isset($param->CallbackParameter->searchCriteria) || count($serachCriteria = json_decode(json_encode($param->CallbackParameter->searchCriteria), true)) === 0) {
             throw new Exception('System Error: search criteria not provided!');
         }
         $pageNo = 1;
         $pageSize = DaoQuery::DEFAUTL_PAGE_SIZE;
         if (isset($param->CallbackParameter->pagination)) {
             $pageNo = $param->CallbackParameter->pagination->pageNo;
             $pageSize = $param->CallbackParameter->pagination->pageSize;
         }
         $noSearch = true;
         $where = array(1);
         $params = array();
         foreach ($serachCriteria as $field => $value) {
             if (is_array($value) && count($value) === 0 || is_string($value) && ($value = trim($value)) === '') {
                 continue;
             }
             OrderItem::getQuery()->eagerLoad("OrderItem.order", 'inner join', 'ord', 'ord.id = ord_item.orderId');
             switch ($field) {
                 case 'ord.orderNo':
                 case 'ord.invNo':
                     $where[] = $field . " like ? ";
                     $params[] = $value . '%';
                     break;
                 case 'ord_item.isOrdered':
                     $where[] = $field . " = ? ";
                     $params[] = $value;
                     break;
                 case 'ord_item.eta.from':
                     $where[] = 'ord_item.eta >= ?';
                     $params[] = $value;
                     break;
                 case 'ord_item.eta.to':
                     $where[] = 'ord_item.eta <= ?';
                     $params[] = $value;
                     break;
             }
             $noSearch = false;
         }
         if ($noSearch === true) {
             throw new Exception("Nothing to search!");
         }
         $stats = array();
         $orderItems = OrderItem::getAllByCriteria(implode(' AND ', $where), $params, true, $pageNo, $pageSize, array('ord_item.eta' => 'asc', 'ord.orderNo' => 'asc'), $stats);
         $results['pageStats'] = $stats;
         $results['items'] = array();
         foreach ($orderItems as $item) {
             $orderItemArray = $item->getJson();
             $comments = Comments::getAllByCriteria('entityName = ? and entityId = ?', array('OrderItem', $item->getId()), true, null, DaoQuery::DEFAUTL_PAGE_SIZE, array('created' => 'desc'));
             $orderItemArray['comments'] = array_map(create_function('$a', 'return $a->getJson();'), $comments);
             $results['items'][] = $orderItemArray;
         }
     } catch (Exception $ex) {
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:68,代码来源:OrderItemController.php

示例4: saveOrder

 /**
  * saveOrder
  *
  * @param unknown $sender
  * @param unknown $param
  *
  * @throws Exception
  *
  */
 public function saveOrder($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         $customer = Customer::get(trim($param->CallbackParameter->customer->id));
         if (!$customer instanceof Customer) {
             throw new Exception('Invalid Customer passed in!');
         }
         if (!isset($param->CallbackParameter->applyTo) || ($applyTo = trim($param->CallbackParameter->applyTo)) === '' || !in_array($applyTo, CreditNote::getApplyToTypes())) {
             throw new Exception('Invalid Apply To passed in!');
         }
         if (isset($param->CallbackParameter->creditNoteId) && ($creditNote = CreditNote::get(trim($param->CallbackParameter->creditNoteId))) instanceof CreditNote) {
             $creditNote = $creditNote;
         } else {
             if (isset($param->CallbackParameter->orderId) && ($order = Order::get(trim($param->CallbackParameter->orderId))) instanceof Order) {
                 $creditNote = CreditNote::createFromOrder($order, $customer, trim($param->CallbackParameter->description));
             } else {
                 $creditNote = CreditNote::create($customer, trim($param->CallbackParameter->description));
             }
         }
         $creditNote->setShippingValue(isset($param->CallbackParameter->totalShippingCost) ? StringUtilsAbstract::getValueFromCurrency($param->CallbackParameter->totalShippingCost) : 0);
         if (isset($param->CallbackParameter->shippingAddr)) {
             $shippAddress = Address::create($param->CallbackParameter->shippingAddr->street, $param->CallbackParameter->shippingAddr->city, $param->CallbackParameter->shippingAddr->region, $param->CallbackParameter->shippingAddr->country, $param->CallbackParameter->shippingAddr->postCode, $param->CallbackParameter->shippingAddr->contactName, $param->CallbackParameter->shippingAddr->contactNo);
             $customer->setShippingAddress($shippAddress);
         }
         $printItAfterSave = false;
         if (isset($param->CallbackParameter->printIt)) {
             $printItAfterSave = intval($param->CallbackParameter->printIt) === 1 ? true : false;
         }
         if (isset($param->CallbackParameter->comments)) {
             $comments = trim($param->CallbackParameter->comments);
             $creditNote->addComment($comments, Comments::TYPE_SALES);
         }
         $totalPaymentDue = $creditNote->getShippingValue();
         $hasShipped = $creditNote->getOrder() instanceof Order && Shippment::countByCriteria('orderId = ?', array($creditNote->getOrder()->getId())) > 0;
         $creditNoteItemsMap = array();
         foreach ($param->CallbackParameter->items as $item) {
             if (!($product = Product::get(trim($item->product->id))) instanceof Product) {
                 throw new Exception('Invalid Product passed in!');
             }
             $unitPrice = StringUtilsAbstract::getValueFromCurrency(trim($item->unitPrice));
             $qtyOrdered = trim($item->qtyOrdered);
             $totalPrice = StringUtilsAbstract::getValueFromCurrency(trim($item->totalPrice));
             $itemDescription = trim($item->itemDescription);
             $active = trim($item->valid);
             $totalPaymentDue += $totalPrice;
             if (is_numeric($item->creditNoteItemId) && !CreditNoteItem::get(trim($item->creditNoteItemId)) instanceof CreditNoteItem) {
                 throw new Exception('Invalid Credit Note Item passed in');
             }
             $unitCost = $product->getUnitCost();
             $orderItem = null;
             if (isset($item->orderItemId) && ($orderItem = OrderItem::get(trim($item->orderItemId))) instanceof OrderItem) {
                 $unitCost = $orderItem->getUnitCost();
             }
             $creditNoteItem = is_numeric($item->creditNoteItemId) ? CreditNoteItem::get(trim($item->creditNoteItemId))->setActive($active)->setProduct($product)->setQty($qtyOrdered)->setUnitPrice($unitPrice)->setItemDescription($itemDescription)->setUnitCost($unitCost)->setTotalPrice($totalPrice)->save() : ($orderItem instanceof OrderItem ? CreditNoteItem::createFromOrderItem($creditNote, $orderItem, $qtyOrdered, $unitPrice, $itemDescription, $unitCost, $totalPrice) : CreditNoteItem::create($creditNote, $product, $qtyOrdered, $unitPrice, $itemDescription, $unitCost, $totalPrice));
             if (intval($creditNoteItem->getActive()) === 1) {
                 if (!isset($creditNoteItemsMap[$product->getId()])) {
                     $creditNoteItemsMap[$product->getId()] = 0;
                 }
                 $creditNoteItemsMap[$product->getId()] += $qtyOrdered;
             }
             //if we are not creating from a order, or there are shippments for this order then
             if (!$creditNote->getOrder() instanceof Order || $hasShipped === true) {
                 switch (trim($item->stockData)) {
                     case 'StockOnHand':
                         $product->returnedIntoSOH($qtyOrdered, $creditNoteItem->getUnitCost(), '', $creditNoteItem);
                         break;
                     case 'StockOnRMA':
                         $product->returnedIntoRMA($qtyOrdered, $creditNoteItem->getUnitCost(), '', $creditNoteItem);
                         break;
                     default:
                         throw new Exception('System Error: NO where to transfer the stock: ' . trim($item->stockData) . ' for product(SKU=' . $product->getSku() . ').');
                 }
             } else {
                 //revert all the shipped stock
                 foreach (OrderItem::getAllByCriteria('ord_item.orderId = ? and ord_item.isShipped = 1', array($creditNote->getOrder()->getId())) as $orderItem) {
                     $orderItem->setIsShipped(false)->save();
                 }
                 //revert all the picked stock
                 foreach (OrderItem::getAllByCriteria('ord_item.orderId = ? and ord_item.isPicked = 1', array($creditNote->getOrder()->getId())) as $orderItem) {
                     $orderItem->setIsPicked(false)->save();
                 }
             }
         }
         if (($paymentMethod = PaymentMethod::get(trim($param->CallbackParameter->paymentMethodId))) instanceof PaymentMethod) {
             $creditNote->setTotalPaid($totalPaidAmount = $param->CallbackParameter->totalPaidAmount)->addPayment($paymentMethod, $totalPaidAmount);
         }
         $creditNote->setTotalValue($totalPaymentDue)->setApplyTo($applyTo)->save();
         //if need to check half credited orders
         if ($creditNote->getOrder() instanceof Order && $hasShipped === false) {
//.........这里部分代码省略.........
开发者ID:larryu,项目名称:magento-b2b,代码行数:101,代码来源:DetailsController.php

示例5: searchProduct

 /**
  * Searching searchProduct
  *
  * @param unknown $sender
  * @param unknown $param
  *
  * @throws Exception
  *
  */
 public function searchProduct($sender, $param)
 {
     $results = $errors = array();
     try {
         $items = array();
         $searchTxt = isset($param->CallbackParameter->searchTxt) ? trim($param->CallbackParameter->searchTxt) : '';
         $customer = isset($param->CallbackParameter->customerId) ? Customer::get(trim($param->CallbackParameter->customerId)) : null;
         $where = 'pro_pro_code.code = :searchExact or pro.name like :searchTxt OR sku like :searchTxt';
         $params = array('searchExact' => $searchTxt, 'searchTxt' => '%' . $searchTxt . '%');
         $pageNo = isset($param->CallbackParameter->pageNo) ? trim($param->CallbackParameter->pageNo) : '1';
         $searchTxtArray = StringUtilsAbstract::getAllPossibleCombo(StringUtilsAbstract::tokenize($searchTxt));
         if (count($searchTxtArray) > 1) {
             foreach ($searchTxtArray as $index => $comboArray) {
                 $key = 'combo' . $index;
                 $where .= ' OR pro.name like :' . $key;
                 $params[$key] = '%' . implode('%', $comboArray) . '%';
             }
         }
         $supplierID = isset($param->CallbackParameter->supplierID) ? trim($param->CallbackParameter->supplierID) : '';
         Product::getQuery()->eagerLoad('Product.codes', 'left join');
         $stats = array();
         $products = Product::getAllByCriteria($where, $params, true, $pageNo, DaoQuery::DEFAUTL_PAGE_SIZE, array('pro.sku' => 'asc'), $stats);
         foreach ($products as $product) {
             $jsonArray = $product->getJson();
             $jsonArray['lastOrderItemFromCustomer'] = array();
             if ($customer instanceof Customer) {
                 $query = OrderItem::getQuery()->eagerLoad('OrderItem.order', 'inner join', 'ord', 'ord_item.orderId = ord.id and ord_item.active = 1 and ord.customerId = :custId and ord.type = :ordType');
                 $orderItems = OrderItem::getAllByCriteria('productId = :prodId', array('custId' => $customer->getId(), 'prodId' => $product->getId(), 'ordType' => Order::TYPE_INVOICE), true, 1, 1, array('ord_item.id' => 'desc'));
                 $jsonArray['lastOrderItemFromCustomer'] = count($orderItems) > 0 ? $orderItems[0]->getJson() : array();
             }
             $items[] = $jsonArray;
         }
         $results['items'] = $items;
         $results['pagination'] = $stats;
     } catch (Exception $ex) {
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:48,代码来源:OrderController.php

示例6: saveOrder

 /**
  * saveOrder
  *
  * @param unknown $sender
  * @param unknown $param
  *
  * @throws Exception
  *
  */
 public function saveOrder($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         $items = array();
         $purchaseOrder = PurchaseOrder::get(trim($param->CallbackParameter->purchaseOrder->id));
         if (!$purchaseOrder instanceof PurchaseOrder) {
             throw new Exception('Invalid PurchaseOrder passed in!');
         }
         $comment = trim($param->CallbackParameter->comments);
         $purchaseOrder->addComment(Comments::TYPE_WAREHOUSE, $comment);
         $products = $param->CallbackParameter->products;
         $outStandingOrders = array();
         $invoiceNos = array();
         foreach ($products->matched as $item) {
             $product = Product::get(trim($item->product->id));
             if (!$product instanceof Product) {
                 throw new Exception('Invalid Product passed in!');
             }
             if (isset($item->product->EANcode)) {
                 $EANcode = trim($item->product->EANcode);
                 $productcodes = ProductCode::getAllByCriteria('pro_code.productId = :productId and pro_code.typeId = :typeId', array('productId' => $product->getId(), 'typeId' => ProductCodeType::ID_EAN), true, 1, 1);
                 if (count($productcodes) > 0) {
                     $productcodes[0]->setCode($EANcode)->save();
                 } else {
                     ProductCode::create($product, ProductCodeType::get(ProductCodeType::ID_EAN), $EANcode);
                 }
             }
             if (isset($item->product->UPCcode)) {
                 $UPCcode = trim($item->product->UPCcode);
                 $productcodes = ProductCode::getAllByCriteria('pro_code.productId = :productId and pro_code.typeId = :typeId', array('productId' => $product->getId(), 'typeId' => ProductCodeType::ID_UPC), true, 1, 1);
                 if (sizeof($productcodes)) {
                     $productcodes[0]->setCode($UPCcode)->save();
                 } else {
                     ProductCode::create($product, ProductCodeType::get(ProductCodeType::ID_UPC), $UPCcode);
                 }
             }
             if (isset($item->product->warehouseLocation) && ($locationName = trim($item->product->warehouseLocation)) !== '') {
                 $locs = Location::getAllByCriteria('name = ?', array($locationName), true, 1, 1);
                 $loc = count($locs) > 0 ? $locs[0] : Location::create($locationName, $locationName);
                 $product->addLocation(PreferredLocationType::get(PreferredLocationType::ID_WAREHOUSE), $loc);
             }
             $serials = $item->serial;
             $totalQty = 0;
             foreach ($serials as $serial) {
                 $qty = trim($serial->qty);
                 $totalQty += intval($qty);
                 $serialNo = trim($serial->serialNo);
                 $unitPrice = trim($serial->unitPrice);
                 $invoiceNo = trim($serial->invoiceNo);
                 $invoiceNos[] = $invoiceNo;
                 $comments = trim($serial->comments);
                 ReceivingItem::create($purchaseOrder, $product, $unitPrice, $qty, $serialNo, $invoiceNo, $comments);
             }
             OrderItem::getQuery()->eagerLoad('OrderItem.order', 'inner join', 'ord', 'ord.id = ord_item.orderId and ord.active = 1 and ord.type = :ordType and ord_item.productId = :productId and ord.statusId in ( :statusId1, :statusId2, :statusId3)');
             $orderItems = OrderItem::getAllByCriteria('ord_item.active = 1', array('ordType' => Order::TYPE_INVOICE, 'productId' => $product->getId(), 'statusId1' => OrderStatus::ID_INSUFFICIENT_STOCK, 'statusId2' => OrderStatus::ID_ETA, 'statusId3' => OrderStatus::ID_STOCK_CHECKED_BY_PURCHASING));
             if (count($orderItems) > 0) {
                 $orders = array();
                 foreach ($orderItems as $orderItem) {
                     if (!array_key_exists($orderItem->getOrder()->getId(), $orders)) {
                         $orders[$orderItem->getOrder()->getId()] = $orderItem->getOrder()->getJson();
                     }
                 }
                 $outStandingOrders[$product->getId()] = array('product' => $product->getJson(), 'recievedQty' => $totalQty, 'outStandingOrders' => array_values($orders));
             }
         }
         $results['outStandingOrders'] = count($outStandingOrders) > 0 ? array_values($outStandingOrders) : array();
         $results['item'] = PurchaseOrder::get($purchaseOrder->getId())->getJson();
         $invoiceNos = array_unique($invoiceNos);
         $results['invoiceNos'] = $invoiceNos;
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:87,代码来源:ReceivingController.php

示例7: postSave

 /**
  * (non-PHPdoc)
  * @see BaseEntityAbstract::postSave()
  */
 public function postSave()
 {
     if (trim($this->getOrderNo()) === '') {
         $this->setOrderNo('BPCM' . str_pad($this->getId(), 8, '0', STR_PAD_LEFT))->setMargin($this->getCalculatedTotalMargin())->save();
     }
     if (trim($this->getType()) === trim(self::TYPE_INVOICE)) {
         $this->_changeToInvoice();
     }
     //if the order is now SHIPPED
     if (trim($this->getStatus()->getId()) === trim(OrderStatus::ID_SHIPPED)) {
         $items = OrderItem::getAllByCriteria('orderId = ? and isPicked = 1', array($this->getId()));
         foreach ($items as $item) {
             $item->setIsShipped(true)->save();
         }
         $this->_changeToInvoice();
     } elseif (trim($this->getStatus()->getId()) === trim(OrderStatus::ID_CANCELLED)) {
         //if the order is now cancelled
         //we need to unlink all the kits that were provided in this order item for sale.
         SellingItem::getQuery()->eagerLoad('SellingItem.orderItem', 'inner join', 'rec_item_oi', 'rec_item_oi.id = sell_item.orderItemId and sell_item.active = 1 and sell_item.kitId is not null');
         $items = SellingItem::getAllByCriteria('rec_item_oi.orderId = ? and rec_item_oi.isShipped = 0', array($this->getId()));
         foreach ($items as $item) {
             $item->setActive(false)->save();
         }
     }
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:29,代码来源:Order.php


注:本文中的OrderItem::getAllByCriteria方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。