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


PHP Kit::getAllByCriteria方法代码示例

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


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

示例1: preSave

 /**
  * (non-PHPdoc)
  * @see BaseEntityAbstract::preSave()
  */
 public function preSave()
 {
     if (intVal($this->getActive()) === 1) {
         $sku = trim($this->getSku());
         $where = array('sku = ?');
         $params = array($sku);
         if (($id = trim($this->getId())) !== '') {
             $where[] = 'id != ?';
             $params[] = $id;
         }
         $exsitingSKU = self::countByCriteria(implode(' AND ', $where), $params);
         if ($exsitingSKU > 0) {
             throw new EntityException('The SKU(=' . $sku . ') is already exists!');
         }
         if ($this->attributeSet instanceof ProductAttributeSet && $this->attributeSet->getId() === '' || !$this->attributeSet instanceof ProductAttributeSet) {
             $this->setAttributeSet(ProductAttributeSet::get(ProductAttributeSet::ID_DEFAULT_ATTR_SET));
         }
     }
     if (($id = trim($this->getId())) !== '') {
         if (self::countByCriteria('id = ? and isKit = 1 and isKit != ?', array($id, $this->getIsKit())) > 0) {
             //changing isKit flag to be not a KIT
             if (count($kits = Kit::getAllByCriteria('productId = ?', array($id), true, 1, 1)) > 0) {
                 throw new EntityException('Can NOT change the flag IsKit, as there are kits like [' . $kits[0]->getBarcode() . '] for this product: ' . $this->getSku());
             }
         }
     }
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:31,代码来源:Product.php

示例2: postSave

 /**
  * (non-PHPdoc)
  * @see BaseEntityAbstract::postSave()
  */
 public function postSave()
 {
     if ($this->getOrder() instanceof Order) {
         if (count($kits = Kit::getAllByCriteria('soldOnOrderId = ? and shippmentId is null', array($this->getOrder()->getId()))) > 0) {
             foreach ($kits as $kit) {
                 if (!$kit->getShippment() instanceof Shippment) {
                     $kit->setShippment($this)->save();
                 }
             }
         }
     }
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:16,代码来源:Shippment.php

示例3: preSave

 /**
  * (non-PHPdoc)
  * @see BaseEntityAbstract::preSave()
  */
 public function preSave()
 {
     if (trim($this->getInvDate()) === '') {
         $this->setInvDate(Udate::zeroDate());
     }
     if (trim($this->getId()) !== '') {
         //status changed
         $originalOrder = self::get($this->getId());
         if ($originalOrder instanceof Order && $originalOrder->getStatus()->getId() !== $this->getStatus()->getId()) {
             $infoType = OrderInfoType::get(OrderInfoType::ID_MAGE_ORDER_STATUS_BEFORE_CHANGE);
             $orderInfos = OrderInfo::find($this, $infoType, false, 1, 1);
             $orderInfo = count($orderInfos) === 0 ? null : $orderInfos[0];
             OrderInfo::create($this, $infoType, $originalOrder->getStatus()->getId(), $orderInfo);
             $this->addLog('Changed Status from [' . $originalOrder->getStatus()->getName() . '] to [' . $this->getStatus() . ']', Log::TYPE_SYSTEM, 'Auto Log', get_class($this) . '::' . __FUNCTION__);
             //get the required kits qty
             if (in_array(intval($this->getStatus()->getId()), array(OrderStatus::ID_PICKED, OrderStatus::ID_SHIPPED))) {
                 $sql = "select sum(ord_item.qtyOrdered) `requiredQty`, ord_item.productId `productId`, pro.sku `sku` from orderitem ord_item inner join product pro on (pro.id = ord_item.productId and pro.isKit = 1) where ord_item.orderId = ? and ord_item.active = 1 group by pro.id";
                 $result = Dao::getResultsNative($sql, array($this->getId()), PDO::FETCH_ASSOC);
                 if (count($result) > 0) {
                     $errMsg = array();
                     foreach ($result as $row) {
                         $requiredQty = $row['requiredQty'];
                         $sku = $row['sku'];
                         if (($kitsCount = count($kits = Kit::getAllByCriteria('soldOnOrderId = ? and productId =? ', array($this->getId(), $row['productId'])))) < $requiredQty) {
                             $errMsg[] = 'Product (SKU=' . $sku . ') needs to be sold as a kit(req Qty=' . $requiredQty . ', providedQty=' . $kitsCount . '): ' . implode(', ', array_map(create_function('$a', 'return $a->getBarcode();'), $kits));
                         }
                     }
                     if (count($errMsg) > 0) {
                         throw new EntityException(implode('; ', $errMsg));
                     }
                 }
             }
         }
     }
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:39,代码来源:Order.php


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