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


PHP ProductCategory::descendantsIds方法代碼示例

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


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

示例1: searchFrontend

 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  */
 public function searchFrontend($criteria = false, $category = false)
 {
     if (!$criteria) {
         $criteria = new SDbCriteria();
     }
     $criteria->compare('active', self::ACTIVE);
     if ($this->searchNameIndex) {
         $criteria->compare('name_index', $this->searchNameIndex, true);
     } else {
         $criteria->compare('id_brand', $this->id_brand);
         $criteria->group = 't.id';
         if ($this->price) {
             list($priceFrom, $priceTo) = explode(',', $this->price);
             $criteria->addCondition("price >= :priceFrom AND price <= :priceTo");
             $criteria->params += [':priceFrom' => $priceFrom, ':priceTo' => $priceTo];
         }
         $criteria->together = true;
     }
     if ($category) {
         $criteria->compare('t.id_category', ProductCategory::descendantsIds($category->id, true));
     }
     if (!$this->searchNameIndex) {
         //Для получения минимальной и максимальной цены продукта, чтобы проставить в фильтре цены
         $builder = new CDbCommandBuilder(Yii::app()->db->getSchema());
         $minMaxPriceCriteria = clone $criteria;
         $minMaxPriceCriteria->select = "t.price";
         $command = $builder->createFindCommand(Product::model()->tableName(), $minMaxPriceCriteria);
         $result = $command->queryColumn();
         if ($result) {
             $this->max_price = max($result);
         }
         if ($this->productOptions) {
             $criteria->with[] = 'options';
             $criteria->compare('options.id_variation', $this->productOptions);
         }
     }
     $pageSize = Cookie::get('product-list-view') == 'thumbnail' ? self::PAGESIZE_THUMBNAIL : self::PAGESIZE_LIST;
     return new SActiveDataProvider($this, array('criteria' => $criteria, 'pagination' => array('pageSize' => $pageSize, 'pageVar' => 'page'), 'sort' => ['attributes' => ['price', 'name', 'viewed']]));
 }
開發者ID:amanukian,項目名稱:test,代碼行數:43,代碼來源:Product.php


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