当前位置: 首页>>代码示例>>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;未经允许,请勿转载。