本文整理汇总了PHP中common\models\Product::LoadList方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::LoadList方法的具体用法?PHP Product::LoadList怎么用?PHP Product::LoadList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common\models\Product
的用法示例。
在下文中一共展示了Product::LoadList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionSearch
/**
* Страница поиска
*/
public function actionSearch()
{
$this->showSearchBlock = true;
$this->openAdvSearchBlock = true;
$searchQuery = Yii::$app->request->get('q');
$searchQueryPrice_min = (int) Yii::$app->request->get('price_min');
$searchQueryPrice_max = (int) Yii::$app->request->get('price_max');
$searchQueryCat = (int) Yii::$app->request->get('cat');
$searchQueryOrg = (array) Yii::$app->request->get('org');
$searchQuerySpec = (int) Yii::$app->request->get('spec');
$searchQuerySpecType = (int) Yii::$app->request->get('spec_type');
$searchQueryDiagnos = (int) Yii::$app->request->get('diagnos');
$query = Product::find()->joinWith(['type']);
// Поисковой запрос
if ($searchQuery) {
$query->where(['like', 'keywords', $searchQuery]);
} else {
$query->where([]);
}
if ($searchQuerySpecType) {
$query->joinWith(['specType'])->andFilterWhere(['tbl_specialist_has_type.spec_type_id' => $searchQuerySpecType, 'tbl_specialist_type.id' => $searchQuerySpecType]);
}
if ($searchQueryDiagnos) {
$query->joinWith(['diagnos'])->andFilterWhere(['tbl_product_type_has_diagnos.diagnos_id' => $searchQueryDiagnos, 'tbl_diagnos.id' => $searchQueryDiagnos]);
}
//если указана цена
if ($searchQueryPrice_min > 0 && $searchQueryPrice_max > 0) {
$query->andFilterWhere([">", 'price_discount', $searchQueryPrice_min]);
$query->andFilterWhere(["<", 'price_discount', $searchQueryPrice_max]);
}
//если указана категория или тип заболевания
if ($searchQueryCat > 0) {
$query->andFilterWhere(['cat_id' => $searchQueryCat]);
}
//Если указаны организации
if (count($searchQueryOrg) > 0) {
$query->andFilterWhere(['in', 'organization_id', $searchQueryOrg]);
}
//если указан специалист
if ($searchQuerySpec) {
$query->andFilterWhere(['specialist_id' => $searchQuerySpec]);
}
//http://ihealthdev.upmc.ru/search?q=%D0%BB%D0%B5%D1%87%D0%B5%D0%BD%D0%B8%D0%B5&price_min=1000&price_max=200000&cat=21&org=7&spec_type=2&spec=2
//echo $query->createCommand()->getRawSql();
//die;
$countQuery = clone $query;
$pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 20]);
$_productList = $query->offset($pages->offset)->limit($pages->limit)->with(['type', 'organization', 'specialist'])->asArray()->all();
//Получаем новые поля price_format и price_discount_format в виде number_format
Product::format($_productList);
//Заболевания диагноз parent_id > 0
//$catList = ArrayHelper::index( ProductCat::find()->where(['>','parent_id',0])->asArray()->all(), 'id' );
//Список организаций
//$orgList = ArrayHelper::index(Organization::find()->asArray()->all(), 'id');
//Список специалистов
//$specList = ArrayHelper::index(Specialist::find()->asArray()->all(), 'id');
$productList = ['diagnost' => ['title' => 'Диагностика', 'desc' => 'Уточните свой диагноз и проблемную область', 'list' => []], 'program' => ['title' => 'Программы лечения', 'desc' => 'Посмотрите программы лечения и выберите свой курс лечения', 'list' => []], 'spec' => ['title' => 'Специалисты', 'desc' => 'Проконсультируйтесь с ведущими специлистами', 'list' => []]];
foreach ($_productList as $item) {
if ($item['type']) {
if ($item['specialist_id'] > 0) {
$productList['spec']['list'][$item['id']] = $item;
} elseif ($item['type']['type_index'] == 1) {
$productList['diagnost']['list'][$item['id']] = $item;
} elseif ($item['type']['type_index'] == 2) {
$productList['program']['list'][$item['id']] = $item;
}
}
}
/*print '<pre>';
echo count($productList['spec']['list']);
print_r ($productList['spec']['list']);
print '</pre>';
die;*/
// RightBlock data
$typeIds = ArrayHelper::getColumn($_productList, 'type_id');
$blockData['productList'] = Product::LoadList('*', 'priority > 0', 'priority desc', 3);
$blockData['orgList'] = Organization::LoadList('*', 'priority > 0', 'priority desc', 2);
return $this->render('search', ['query' => $searchQuery, 'productList' => $productList, 'productPages' => $pages, 'blockData' => $blockData]);
}