當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Kit::getByBarcode方法代碼示例

本文整理匯總了PHP中Kit::getByBarcode方法的典型用法代碼示例。如果您正苦於以下問題:PHP Kit::getByBarcode方法的具體用法?PHP Kit::getByBarcode怎麽用?PHP Kit::getByBarcode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Kit的用法示例。


在下文中一共展示了Kit::getByBarcode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: preSave

 /**
  * (non-PHPdoc)
  * @see BaseEntityAbstract::preSave()
  */
 public function preSave()
 {
     if (trim($this->getSerialNo()) === '') {
         throw new Exception('You can NOT save a selling Item without a serial number.');
     }
     if (trim($this->getId()) !== '') {
         if (intval($this->getActive()) === 0 && self::countByCriteria('id = ? and active != ?', array($this->getId(), $this->getActive())) > 0) {
             //trying to deactivated
             $this->_clearKit();
         } else {
             if (intval($this->getActive()) === 1 && self::countByCriteria('id = ? and serialNo != ?', array($this->getId(), trim($this->getSerialNo()))) > 0) {
                 //trying to changed serialno
                 $this->_clearKit()->setKit(null);
             }
         }
     }
     if ($this->getOrderItem() instanceof OrderItem) {
         $this->setProduct($this->getOrderItem()->getProduct())->setOrder($this->getOrderItem()->getOrder());
     }
     if (!$this->getKit() instanceof Kit && strpos(trim($this->getSerialNo()), Kit::BARCODE_PREFIX) === 0) {
         if (($kit = Kit::getByBarcode(trim($this->getSerialNo()))) instanceof Kit) {
             $this->setKit($kit);
         }
     }
     if ($this->getKit() instanceof Kit) {
         $kitProduct = $this->getKit()->getProduct();
         $orderItemProduct = $this->getOrderItem() instanceof OrderItem ? $this->getOrderItem()->getProduct() : null;
         if (!$kitProduct instanceof Product && $orderItemProduct instanceof Product || $kitProduct instanceof Product && !$orderItemProduct instanceof Product || $kitProduct instanceof Product && $orderItemProduct instanceof Product && $kitProduct->getId() !== $orderItemProduct->getId()) {
             throw new Exception('The Kit [' . $this->getKit()->getBarcode() . ', SKU: ' . ($kitProduct instanceof Product ? $kitProduct->getSku() : '') . '] is not the same product on this OrderItem[SKU:' . ($orderItemProduct instanceof Product ? $orderItemProduct->getSku() : '') . '].');
         }
     }
     if ($this->getProduct() instanceof Product && intval($this->getProduct()->getIsKit()) === 1) {
         if (!$this->getKit() instanceof Kit) {
             throw new Exception('The Product(SKU: ' . $this->getProduct()->getSku() . ') is a KIT, but no valid Kit barcode provided(Provided: ' . $this->getSerialNo() . ').');
         }
         if ($this->getOrderItem()->getOrder() instanceof Order) {
             $where = array('kitId = :kitId and orderId = :orderId and active = 1');
             $params = array('kitId' => $this->getKit()->getId(), 'orderId' => $this->getOrderItem()->getOrder()->getId());
             if (($id = trim($this->getId())) !== '') {
                 $where[] = 'id != :id';
                 $params['id'] = $id;
             }
             if (self::countByCriteria(implode(' AND ', $where), $params) > 0) {
                 throw new Exception('The KIT[' . $this->getKit()->getBarcode() . '] has been scanned onto this Order(' . $this->getOrderItem()->getOrder()->getOrderNo() . ') already!');
             }
         }
     }
 }
開發者ID:larryu,項目名稱:magento-b2b,代碼行數:52,代碼來源:SellingItem.php


注:本文中的Kit::getByBarcode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。