本文整理汇总了PHP中app\modules\shop\models\Product::tableName方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::tableName方法的具体用法?PHP Product::tableName怎么用?PHP Product::tableName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\modules\shop\models\Product
的用法示例。
在下文中一共展示了Product::tableName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: down
public function down()
{
$this->dropColumn(Category::tableName(), 'date_added');
$this->dropColumn(Category::tableName(), 'date_modified');
$this->dropColumn(Product::tableName(), 'date_added');
$this->dropColumn(Product::tableName(), 'date_modified');
}
示例2: up
public function up()
{
$this->addColumn(Page::tableName(), 'mate_keywords', $this->string()->defaultValue(null));
$this->addColumn(Product::tableName(), 'mate_keywords', $this->string()->defaultValue(null));
$this->addColumn(Category::tableName(), 'mate_keywords', $this->string()->defaultValue(null));
$this->addColumn(PrefilteredPages::tableName(), 'mate_keywords', $this->string()->defaultValue(null));
}
示例3: run
/**
* @return string
*/
public function run()
{
parent::run();
if (null === $this->rootCategory) {
return '';
}
$cacheKey = $this->className() . ':' . implode('_', [$this->viewFile, $this->rootCategory, null === $this->depth ? 'null' : intval($this->depth), intval($this->includeRoot), intval($this->fetchModels), intval($this->onlyNonEmpty), implode(',', $this->excludedCategories), \Yii::$app->request->url]) . ':' . json_encode($this->additional);
if (false !== ($cache = \Yii::$app->cache->get($cacheKey))) {
return $cache;
}
/** @var array|Category[] $tree */
$tree = Category::getMenuItems(intval($this->rootCategory), $this->depth, boolval($this->fetchModels));
if (true === $this->includeRoot) {
if (null !== ($_root = Category::findById(intval($this->rootCategory)))) {
$tree = [['label' => $_root->name, 'url' => Url::toRoute(['@category', 'category_group_id' => $_root->category_group_id, 'last_category_id' => $_root->id]), 'id' => $_root->id, 'model' => $this->fetchModels ? $_root : null, 'items' => $tree]];
}
}
if (true === $this->onlyNonEmpty) {
$_sq1 = (new Query())->select('main_category_id')->distinct()->from(Product::tableName());
$_sq2 = (new Query())->select('category_id')->distinct()->from('{{%product_category}}');
$_query = (new Query())->select('id')->from(Category::tableName())->andWhere(['not in', 'id', $_sq1])->andWhere(['not in', 'id', $_sq2])->all();
$this->excludedCategories = array_merge($this->excludedCategories, array_column($_query, 'id'));
}
$tree = $this->filterTree($tree);
$cache = $this->render($this->viewFile, ['tree' => $tree, 'fetchModels' => $this->fetchModels, 'additional' => $this->additional, 'activeClass' => $this->activeClass, 'activateParents' => $this->activateParents]);
\Yii::$app->cache->set($cacheKey, $cache, 0, new TagDependency(['tags' => [ActiveRecordHelper::getCommonTag(Category::className()), ActiveRecordHelper::getCommonTag(Product::className())]]));
return $cache;
}
示例4: editQuery
public static function editQuery(SearchEvent $event)
{
/** @var \app\modules\shop\ShopModule $module */
$module = \Yii::$app->modules['shop'];
$event->activeQuery->select('`id`')->from(Product::tableName())->orWhere('`name` LIKE :q')->orWhere('`h1` LIKE :q')->orWhere('`content` LIKE :q')->orWhere('`sku` LIKE :q')->addParams([':q' => '%' . $event->q . '%'])->andWhere(['active' => 1]);
if ($module->allowSearchGeneratedProducts != 1) {
$event->activeQuery->andWhere(['parent_id' => 0]);
}
}
示例5: searchProductsByDescription
public function searchProductsByDescription()
{
/** @var \app\modules\shop\ShopModule $module */
$module = Yii::$app->modules['shop'];
$query = (new Query())->select('`id`')->from(Product::tableName())->orWhere('`name` LIKE :q')->orWhere('`h1` LIKE :q')->orWhere('`content` LIKE :q')->orWhere('`sku` LIKE :q')->addParams([':q' => '%' . $this->q . '%'])->andWhere(['active' => 1]);
if ($module->allowSearchGeneratedProducts != 1) {
$query->andWhere(['parent_id' => 0]);
}
return ArrayHelper::getColumn($query->all(), 'id');
}
示例6: filter
/**
* @param ActiveQuery $query
* @return ActiveQuery
*/
public function filter(ActiveQuery $query, &$cacheKeyAppend)
{
$get = Yii::$app->request->get();
$params = array_merge($get, Yii::$app->request->post());
$min = floatval(ArrayHelper::getValue($params, $this->minAttribute, $this->minValue));
$max = floatval(ArrayHelper::getValue($params, $this->maxAttribute, $this->maxValue));
if ($min !== floatval($this->minValue)) {
$cacheKeyAppend .= "[MinPrice:{$min}]";
$query = $query->andWhere(Product::tableName() . '.price >= :min_price', [':min_price' => $min]);
$get[$this->minAttribute] = $min;
}
if ($max !== floatval($this->maxValue) && (double) 0 !== floatval($max)) {
$cacheKeyAppend .= "[MaxPrice:{$max}]";
$query = $query->andWhere(Product::tableName() . '.price <= :max_price', [':max_price' => $max]);
$get[$this->maxAttribute] = $max;
}
Yii::$app->request->setQueryParams($get);
return $query;
}
示例7: filter
/**
* @param ActiveQuery $query
* @return ActiveQuery
*/
public function filter(ActiveQuery $query, &$cacheKeyAppend)
{
$get = array_merge(Yii::$app->request->get(), Yii::$app->request->post());
$isChange = isset($get[$this->changeAttribute]) && $get[$this->changeAttribute] == 1 ? true : false;
$min = floatval(ArrayHelper::getValue($get, $this->minAttribute, $this->minValue));
$max = floatval(ArrayHelper::getValue($get, $this->maxAttribute, $this->maxValue));
if ($min !== floatval($this->minValue) && $isChange) {
$cacheKeyAppend .= "[MinPrice:{$min}]";
$query = $query->andWhere(Product::tableName() . '.price >= :min_price', [':min_price' => $min]);
} else {
ArrayHelper::remove($get, $this->minAttribute);
ArrayHelper::remove($_GET, $this->minAttribute);
Yii::$app->request->setQueryParams($get);
}
if ($max !== floatval($this->maxValue) && $isChange) {
$cacheKeyAppend .= "[MaxPrice:{$max}]";
$query = $query->andWhere(Product::tableName() . '.price <= :max_price', [':max_price' => $max]);
} else {
ArrayHelper::remove($get, $this->maxAttribute);
ArrayHelper::remove($_GET, $this->maxAttribute);
Yii::$app->request->setQueryParams($get);
}
return $query;
}
示例8: up
public function up()
{
mb_internal_encoding(Yii::$app->getModule('core')->internalEncoding);
$data = (include __DIR__ . DIRECTORY_SEPARATOR . 'demo-data.php');
$productObject = Object::getForClass(Product::className());
/** @var PropertyHandler $handler */
$handler = PropertyHandler::findOne(['handler_class_name' => 'app\\properties\\handlers\\text\\TextProperty']);
if (!is_null($handler)) {
$this->textHandlerId = $handler->id;
}
$handler = PropertyHandler::findOne(['handler_class_name' => 'app\\properties\\handlers\\select\\SelectProperty']);
if (!is_null($handler)) {
$this->selectHandlerId = $handler->id;
}
$this->insert(PropertyGroup::tableName(), ['object_id' => $productObject->id, 'name' => 'Общая группа свойств']);
$commonGroupId = $this->db->lastInsertID;
$this->insert(Property::tableName(), ['property_group_id' => $commonGroupId, 'name' => 'Производитель', 'key' => 'vendor', 'property_handler_id' => $this->selectHandlerId, 'handler_additional_params' => '{}', 'has_static_values' => 1, 'has_slugs_in_values' => 1]);
$this->properties['vendor'] = $this->db->lastInsertID;
$staticProperties = ['Тип крепления бура', 'Макс. энергия удара', 'Количество скоростей работы', 'Питание', 'Тип процессора', 'Тип памяти', 'Частота памяти: 1600 МГц', 'Количество слотов памяти', 'Максимальный размер памяти', 'Размер экрана: 15.6 "', 'Тип экрана', 'Тип видеоадаптера'];
foreach ($data as $category) {
$this->insert(Category::tableName(), ['category_group_id' => 1, 'parent_id' => 1, 'name' => $category['name'], 'h1' => $category['name'], 'title' => $category['name'] . ' с доставкой в любой город России и СНГ', 'breadcrumbs_label' => $category['name'], 'slug' => Helper::createSlug($category['name']), 'announce' => $category['content'], 'content' => $category['content']]);
$categoryId = $this->db->lastInsertID;
$this->insert(PropertyGroup::tableName(), ['object_id' => $productObject->id, 'name' => $category['name']]);
$groupId = $this->db->lastInsertID;
foreach ($category['products'] as $product) {
// product
$slug = Helper::createSlug($product['name']);
if (isset($this->products[$slug])) {
$slug = mb_substr($slug, 0, 66) . '-' . uniqid();
}
$this->insert(Product::tableName(), ['parent_id' => 0, 'measure_id' => 1, 'currency_id' => 1, 'sku' => $product['id'], 'main_category_id' => $categoryId, 'name' => $product['name'], 'title' => $product['name'], 'breadcrumbs_label' => $product['name'], 'h1' => $product['name'], 'slug' => $slug, 'announce' => Helper::trimPlain($product['description']), 'content' => $product['description'], 'price' => $product['prices']['min'], 'old_price' => $product['prices']['max']]);
$productId = $this->db->lastInsertID;
$this->products[$slug] = $productId;
// categories
$this->batchInsert('{{%product_category}}', ['category_id', 'object_model_id'], [[1, $productId], [$categoryId, $productId]]);
// property groups
$this->batchInsert(ObjectPropertyGroup::tableName(), ['object_id', 'object_model_id', 'property_group_id'], [[$productObject->id, $productId, $commonGroupId], [$productObject->id, $productId, $groupId]]);
// properties
if (isset($product['vendor'])) {
$this->saveStatic($productId, 'vendor', $product['vendor']);
}
foreach ($product['details']['modelDetails'] as $group) {
foreach ($group['params'] as $property) {
$property['name'] = trim($property['name'], '/ ');
if (in_array($property['name'], $staticProperties)) {
$key = $this->getKey($property['name']);
if (!isset($this->properties[$key])) {
$this->insert(Property::tableName(), ['property_group_id' => $groupId, 'name' => $property['name'], 'key' => $key, 'property_handler_id' => $this->selectHandlerId, 'handler_additional_params' => '{}', 'has_static_values' => 1, 'has_slugs_in_values' => 1]);
$this->properties[$key] = $this->db->lastInsertID;
}
$this->saveStatic($productId, $this->getKey($property['name']), str_replace($property['name'] . ': ', '', $property['value']));
} else {
$this->saveEav($productId, $groupId, $property['name'], str_replace($property['name'] . ': ', '', $property['value']));
}
}
}
// images
$prodPhotos = [];
if (isset($product['photos'])) {
foreach ($product['photos'] as $photo) {
$prodPhotos[] = [$productObject->id, $productId, $photo['name'], $product['name'], $product['name']];
}
}
if (isset($product['mainPhoto']['name'])) {
$prodPhotos[] = [$productObject->id, $productId, $product['mainPhoto']['name'], $product['name'], $product['name']];
}
if (count($prodPhotos) > 0) {
$this->batchInsert(Image::tableName(), ['object_id', 'object_model_id', 'filename', 'image_alt', 'image_title'], $prodPhotos);
}
}
}
srand();
$cdnNumber = rand(1, 2);
$imgUrl = "http://static-{$cdnNumber}.dotplant.ru/demo-photos.zip";
$imagesPath = Yii::getAlias('@webroot/files/');
$imgsFile = $imagesPath . DIRECTORY_SEPARATOR . 'imgs.zip';
if (file_exists($imgsFile) === false) {
$fp = fopen($imgsFile, 'w+');
$ch = curl_init($imgUrl);
curl_setopt($ch, CURLOPT_TIMEOUT, 600);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
curl_close($ch);
fclose($fp);
}
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
echo "\n\nWow! You are running windows! Please unzip {$imgsFile} to {$imagesPath} \n\n";
} else {
passthru('/usr/bin/env unzip -n "' . $imgsFile . '" -d "' . $imagesPath . '"');
}
}
示例9: actionAjaxRelatedProduct
/**
* @return array
*/
public function actionAjaxRelatedProduct()
{
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$result = ['more' => false, 'results' => []];
$search = Yii::$app->request->get('search');
if (!empty($search['term'])) {
$query = new \yii\db\Query();
$query->select('id, name AS text')->from(Product::tableName())->andWhere(['like', 'name', $search['term']])->andWhere(['active' => 1])->orderBy(['sort_order' => SORT_ASC, 'name' => SORT_ASC]);
$command = $query->createCommand();
$data = $command->queryAll();
$result['results'] = array_values($data);
}
return $result;
}
示例10: down
public function down()
{
$this->delete(BackendMenu::tableName(), ['route' => '/shop/backend-measure/index']);
$this->dropColumn(Product::tableName(), 'measure_id');
$this->dropTable(Measure::tableName());
}
示例11: down
public function down()
{
$this->dropTable('{{%user_category}}');
$this->dropTable('{{%user_eav}}');
$this->dropTable('{{%user_property}}');
$this->dropTable(UserService::tableName());
$this->dropTable(User::tableName());
$this->dropTable('{{%auth_assignment}}');
$this->dropTable('{{%auth_item_child}}');
$this->dropTable('{{%auth_item}}');
$this->dropTable('{{%auth_rule}}');
$this->dropTable(ErrorUrl::tableName());
$this->dropTable(ErrorLog::tableName());
$this->dropTable(Review::tableName());
$this->dropTable(Notification::tableName());
$this->dropTable('{{%submission_eav}}');
$this->dropTable('{{%submission_category}}');
$this->dropTable('{{%submission_property}}');
$this->dropTable(Submission::tableName());
$this->dropTable('{{%form_property}}');
$this->dropTable('{{%form_eav}}');
$this->dropTable(Form::tableName());
$this->dropTable('{{%order_category}}');
$this->dropTable('{{%order_eav}}');
$this->dropTable('{{%order_property}}');
$this->dropTable(PaymentType::tableName());
$this->dropTable(ShippingOption::tableName());
$this->dropTable(OrderChat::tableName());
$this->dropTable(OrderTransaction::tableName());
$this->dropTable(OrderItem::tableName());
$this->dropTable(Order::tableName());
$this->dropTable(SubscribeEmail::tableName());
$this->dropTable(CategoryGroupRouteTemplates::tableName());
$this->dropTable('{{%product_category}}');
$this->dropTable('{{%property_category}}');
$this->dropTable('{{%category_eav}}');
$this->dropTable(Category::tableName());
$this->dropTable(CategoryGroup::tableName());
$this->dropTable('{{%page_eav}}');
$this->dropTable('{{%page_category}}');
$this->dropTable('{{%page_property}}');
$this->dropTable(Page::tableName());
$this->dropTable(ViewObject::tableName());
$this->dropTable(View::tableName());
$this->dropTable(Layout::tableName());
$this->dropTable('{{%product_property}}');
$this->dropTable(Product::tableName());
$this->dropTable(Property::tableName());
$this->dropTable(Route::tableName());
$this->dropTable('{{%product_eav}}');
$this->dropTable('{{%product_static_value_full_slug}}');
$this->dropTable('{{%product_category_full_slug}}');
$this->dropTable(PropertyStaticValues::tableName());
$this->dropTable(PropertyHandler::tableName());
$this->dropTable(PropertyGroup::tableName());
$this->dropTable(ObjectStaticValues::tableName());
$this->dropTable(ObjectPropertyGroup::tableName());
$this->dropTable(Object::tableName());
$this->dropTable(DynamicContent::tableName());
$this->dropTable(Navigation::tableName());
$this->dropTable(Image::tableName());
$this->dropTable('{{%session}}');
$this->dropTable(ApiService::tableName());
}
示例12: down
public function down()
{
$this->addColumn(Product::tableName(), 'is_deleted', 'TINYINT UNSIGNED DEFAULT \'0\'');
$this->addColumn(Page::tableName(), 'is_deleted', 'TINYINT UNSIGNED DEFAULT \'0\'');
$this->addColumn(Category::tableName(), 'is_deleted', 'TINYINT UNSIGNED DEFAULT \'0\'');
}
示例13: getPossibleSelections
public function getPossibleSelections()
{
$data = ['propertyIds' => [], 'propertyStaticValueIds' => []];
if ($this->onlyAvailableFilters) {
Yii::beginProfile("onlyAvailableFilters");
$object = Object::findById($this->objectId);
if (!is_null($object) && isset($this->currentSelections['last_category_id'])) {
$cacheKey = 'FilterWidget: ' . $object->id . ':' . $this->currentSelections['last_category_id'] . ':' . Json::encode($this->currentSelections['properties']);
$data = Yii::$app->cache->get($cacheKey);
if ($data === false) {
$data = [];
Yii::beginProfile("ObjectIds for this category");
$query = new Query();
$query = $query->select($object->categories_table_name . '.object_model_id')->distinct()->from($object->categories_table_name)->join("JOIN", Product::tableName(), sprintf("%s.`id` = %s.`object_model_id`", Product::tableName(), $object->categories_table_name))->andWhere([Product::tableName() . ".`active`" => 1])->andWhere(['category_id' => $this->currentSelections['last_category_id']]);
if (count($this->currentSelections['properties']) > 0) {
Yii::beginProfile("Apply currency selections(properties)");
foreach ($this->currentSelections['properties'] as $property_id => $values) {
$joinTableName = 'OSVJoinTable' . $property_id;
$query->join('JOIN', ObjectStaticValues::tableName() . ' ' . $joinTableName, $joinTableName . '.object_id = :objectId AND ' . $joinTableName . '.object_model_id = ' . $object->categories_table_name . '.object_model_id ', [':objectId' => $object->id]);
$query->andWhere(['in', '`' . $joinTableName . '`.`property_static_value_id`', $values]);
}
Yii::endProfile("Apply currency selections(properties)");
}
Yii::endProfile("ObjectIds for this category");
$ids = array_map('intval', $query->column());
$query = null;
Yii::beginProfile("all PSV ids");
$data['propertyStaticValueIds'] = [];
if (count($ids) !== 0) {
$q4psv = (new Query())->select('property_static_value_id')->from(ObjectStaticValues::tableName())->distinct()->where(['object_id' => $object->id])->andWhere('object_model_id in (' . implode(',', $ids) . ')');
$data['propertyStaticValueIds'] = array_map('intval', $q4psv->column());
}
Yii::endProfile("all PSV ids");
$ids = null;
Yii::beginProfile("Property ids from PSV ids");
$data['propertyIds'] = [];
if (count($data['propertyStaticValueIds']) !== 0) {
$data['propertyIds'] = PropertyStaticValues::find()->select('property_id')->distinct()->where(['dont_filter' => 0])->andWhere('id IN (' . implode(',', $data['propertyStaticValueIds']) . ')')->asArray()->column();
}
Yii::endProfile("Property ids from PSV ids");
Yii::$app->cache->set($cacheKey, $data, 86400, new TagDependency(['tags' => [\devgroup\TagDependencyHelper\ActiveRecordHelper::getCommonTag($object->object_class)]]));
$object = null;
}
}
Yii::endProfile("onlyAvailableFilters");
}
$this->possibleSelections = [];
$groups = PropertyGroup::getForObjectId($this->objectId);
foreach ($groups as $group) {
if ($this->onlyGroupsIds !== null) {
if (in_array($group->id, $this->onlyGroupsIds) === false) {
// skip this group
continue;
}
}
if ($group->is_internal) {
continue;
}
$this->possibleSelections[$group->id] = ['group' => $group, 'selections' => [], 'static_selections' => [], 'dynamic_selections' => []];
$props = Property::getForGroupId($group->id);
foreach ($props as $p) {
if ($this->onlyAvailableFilters && !in_array($p->id, $data['propertyIds'])) {
if ($this->disableInsteadOfHide === false) {
continue;
}
}
if ($p->dont_filter) {
continue;
}
if ($p->has_static_values) {
$propertyStaticValues = PropertyStaticValues::getValuesForPropertyId($p->id);
foreach ($propertyStaticValues as $key => $propertyStaticValue) {
if ($propertyStaticValue['dont_filter']) {
unset($propertyStaticValues[$key]);
}
}
if ($this->onlyAvailableFilters) {
foreach ($propertyStaticValues as $key => $propertyStaticValue) {
if (!in_array($propertyStaticValue['id'], $data['propertyStaticValueIds'])) {
if ($this->disableInsteadOfHide === true) {
$this->disabled_ids[] = $propertyStaticValue['id'];
} else {
unset($propertyStaticValues[$key]);
}
}
}
}
$this->possibleSelections[$group->id]['static_selections'][$p->id] = $propertyStaticValues;
} elseif ($p->is_column_type_stored && $p->value_type == 'NUMBER') {
$this->possibleSelections[$group->id]['dynamic_selections'][] = $p->id;
}
}
if (count($this->possibleSelections[$group->id]) === 0) {
unset($this->possibleSelections[$group->id]);
}
}
}
示例14: renderProducts
/**
* renders product item and list.
* possible can render all objects, but need for few logic change
* @param array $chunkData params for select and render
* @param TagDependency $dependency
* @return mixed
*/
private static function renderProducts($chunkData, &$dependency)
{
$params = ['itemView' => Yii::$app->getModule('shop')->itemView, 'type' => 'show', 'object' => 'product', 'where' => [], 'limit' => 0, 'listView' => Yii::$app->getModule('shop')->listView];
switch ($chunkData['key']) {
case 'product':
if (ArrayHelper::keyExists('sku', $chunkData)) {
$params['where'] = ['sku' => $chunkData['sku']];
}
break;
case 'productList':
$params['type'] = 'list';
break;
default:
$expression = '%(?P<objectName>[^#]+?)#(?P<objectId>[\\d]+?)$%';
if (preg_match($expression, $chunkData['key'], $matches)) {
$params['where']['id'] = $matches['objectId'];
}
break;
}
switch ($params['object']) {
case 'product':
$dependency->tags[] = ActiveRecordHelper::getCommonTag(Product::className());
$query = Product::find();
if (!empty($chunkData['categoryId'])) {
$query->leftJoin('{{%product_category}}', Product::tableName() . '.id = {{%product_category}}.object_model_id')->andWhere(['{{%product_category}}.category_id' => $chunkData['categoryId']]);
$dependency->tags[] = ActiveRecordHelper::getCommonTag(Category::className());
$dependency->tags[] = ActiveRecordHelper::getObjectTag(Category::className(), $chunkData['categoryId']);
}
if (!empty($chunkData['property'])) {
$expression = '%(?P<propertyKey>[^:]+?):(?P<propertyValue>.+?)$%';
if (preg_match($expression, $chunkData['property'], $matches)) {
$property = Property::findOne(['key' => $matches['propertyKey']]);
if (!is_null($property)) {
/** @var Property $property */
$dependency->tags[] = ActiveRecordHelper::getCommonTag(Property::className());
$dependency->tags[] = $property->objectTag();
if ($property->is_eav == 1) {
$query->leftJoin('{{%product_eav}}', Product::tableName() . '.id = {{%product_eav}}.object_model_id')->andWhere(['{{%product_eav}}.key' => $matches['propertyKey'], '{{%product_eav}}.value' => $matches['propertyValue']]);
} elseif ($property->has_static_values == 1) {
$psv = PropertyStaticValues::findOne(['property_id' => $property->id, 'value' => $matches['propertyValue']]);
if (!is_null($psv)) {
$dependency->tags[] = ActiveRecordHelper::getCommonTag(PropertyStaticValues::className());
$dependency->tags[] = $psv->objectTag();
$query->leftJoin('{{%object_static_values}}', Product::tableName() . '.id = {{%object_static_values}}.object_model_id')->andWhere(['object_id' => 3, '{{%object_static_values}}.property_static_value_id' => $psv->id]);
} else {
return '';
}
}
/** @todo add column_stored */
} else {
return '';
}
}
}
break;
default:
$query = Product::find();
break;
}
$params = ArrayHelper::merge($params, array_intersect_key($chunkData, $params));
if (!empty($params['where'])) {
$query->andWhere($params['where']);
}
if (!empty($params['limit'])) {
$query->limit($params['limit']);
}
if ($params['type'] === 'list') {
$view = $params['listView'];
$objects = $query->all();
foreach ($objects as $object) {
$dependency->tags[] = $object->objectTag();
}
switch ($params['object']) {
case 'product':
$viewParams = ['products' => $objects];
break;
default:
$viewParams = ['products' => $objects];
break;
}
} else {
$view = $params['itemView'];
$object = $query->one();
if (is_null($object)) {
return '';
}
$dependency->tags[] = $object->objectTag();
switch ($params['object']) {
case 'product':
$viewParams = ['product' => $object, 'url' => Url::to(['@product', 'model' => $object, 'category_group_id' => $object->getMainCategory()->category_group_id])];
break;
default:
$viewParams = ['product' => $object, 'url' => Url::to(['@product', 'model' => $object, 'category_group_id' => $object->getMainCategory()->category_group_id])];
//.........这里部分代码省略.........
示例15: initSubQuery
private static function initSubQuery($category_id, $joinCondition)
{
$subQuery = ObjectStaticValues::find();
return $subQuery->select(ObjectStaticValues::tableName() . '.object_model_id')->innerJoin('{{%product_category}}', '{{%product_category}}.object_model_id = ' . ObjectStaticValues::tableName() . '.object_model_id')->innerJoin(Product::tableName() . ' p', $joinCondition)->where(['category_id' => $category_id]);
}