本文整理汇总了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']]));
}