本文整理汇总了PHP中app\modules\shop\models\Product类的典型用法代码示例。如果您正苦于以下问题:PHP Product类的具体用法?PHP Product怎么用?PHP Product使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Product类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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');
}
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:7,代码来源:m150923_101638_date_modified.php
示例2: getLinks
protected function getLinks()
{
if (!is_null($this->frontendLink) || !is_null($this->backendLink)) {
return true;
}
/** @var Image $image */
$image = Image::findById($this->img_id);
if (is_null($image) || is_null($object = Object::findById($image->object_id))) {
return false;
}
/** @var \app\models\Object $object */
switch ($object->object_class) {
case Page::className():
$this->getPageLinks($image->object_model_id);
break;
case Category::className():
$this->getCategoryLinks($image->object_model_id);
break;
case Product::className():
$this->getProductLinks($image->object_model_id);
break;
default:
return false;
}
return true;
}
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:26,代码来源:ErrorImage.php
示例3: actionEdit
public function actionEdit($id = null)
{
$model = new PrefilteredPages();
$model->loadDefaultValues();
if ($id !== null) {
$model = PrefilteredPages::findOne($id);
}
$static_values_properties = [];
$property_groups_ids_for_object = (new Query())->select('id')->from(PropertyGroup::tableName())->where(['object_id' => Object::getForClass(Product::className())->id])->column();
$properties = Property::find()->andWhere(['in', 'property_group_id', $property_groups_ids_for_object])->all();
foreach ($properties as $prop) {
/** @var Property $prop */
$static_values_properties[$prop->id] = ['property' => $prop, 'static_values_select' => PropertyStaticValues::getSelectForPropertyId($prop->id), 'has_static_values' => $prop->has_static_values === 1];
}
$post = \Yii::$app->request->post();
if ($model->load($post) && $model->validate()) {
$save_result = $model->save();
if ($save_result) {
Yii::$app->session->setFlash('info', Yii::t('app', 'Object saved'));
$returnUrl = Yii::$app->request->get('returnUrl', ['index', 'id' => $model->id]);
switch (Yii::$app->request->post('action', 'save')) {
case 'next':
return $this->redirect(['edit', 'returnUrl' => $returnUrl]);
case 'back':
return $this->redirect($returnUrl);
default:
return $this->redirect(Url::toRoute(['edit', 'id' => $model->id, 'returnUrl' => $returnUrl]));
}
//return $this->redirect(['/backend/prefiltered-pages/edit', 'id' => $model->id]);
} else {
\Yii::$app->session->setFlash('error', Yii::t('app', 'Cannot update data'));
}
}
return $this->render('prefiltered-page-form', ['model' => $model, 'static_values_properties' => $static_values_properties]);
}
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:35,代码来源:BackendPrefilteredPagesController.php
示例4: actionPrint
/**
* @return string
*/
public function actionPrint()
{
$this->layout = 'print';
$products = ProductCompareHelper::getProductsList(true);
$object = Object::getForClass(Product::className());
return $this->render('print', ['error' => empty($products) || null === $object, 'message' => Yii::t('app', 'No products for comparing'), 'object' => $object, 'products' => $products]);
}
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:10,代码来源:ProductCompareController.php
示例5: 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;
}
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:31,代码来源:CategoriesList.php
示例6: 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));
}
开发者ID:HannibalLecktor,项目名称:dotplant2,代码行数:7,代码来源:m160107_092054_add_meta_keywords_1.php
示例7: productsSitemap
protected function productsSitemap($categoryId, $categoryUrl)
{
$product = Product::find()->select(['id', 'slug'])->where(['main_category_id' => $categoryId, 'active' => 1])->asArray(true)->all();
array_reduce($product, function ($carry, $item) use($categoryUrl) {
$this->sitemap->addUrl($categoryUrl . '/' . $item['slug']);
});
}
开发者ID:yii2ApplicationCollect,项目名称:dotplant2,代码行数:7,代码来源:SitemapController.php
示例8: actionIndex
public function actionIndex($category_id = null)
{
$searchModel = new Category();
$searchModel->active = 1;
$params = Yii::$app->request->get();
$dataProvider = $searchModel->search($params);
$selectedCategory = null;
if ($category_id !== null) {
$selectedCategory = Category::findById($category_id);
}
if ($selectedCategory !== null) {
if (Yii::$app->request->isPost === true) {
$newProperty = isset($_GET['add_property_id']) ? Property::findById($_GET['add_property_id']) : null;
if ($newProperty !== null) {
$filterSet = new FilterSets();
$filterSet->category_id = $selectedCategory->id;
$filterSet->property_id = $newProperty->id;
$filterSet->sort_order = 65535;
$filterSet->save();
}
}
}
$groups = PropertyGroup::getForObjectId(Object::getForClass(Product::className())->id, false);
$propertiesDropdownItems = [];
foreach ($groups as $group) {
$item = ['label' => $group->name, 'url' => '#', 'items' => []];
$properties = Property::getForGroupId($group->id);
foreach ($properties as $prop) {
$item['items'][] = ['label' => $prop->name, 'url' => '?category_id=' . $category_id . '&add_property_id=' . $prop->id, 'linkOptions' => ['class' => 'add-property-to-filter-set', 'data-property-id' => $prop->id, 'data-action' => 'post']];
}
$propertiesDropdownItems[] = $item;
}
return $this->render('index', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel, 'selectedCategory' => $selectedCategory, 'propertiesDropdownItems' => $propertiesDropdownItems]);
}
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:34,代码来源:FilterSetsController.php
示例9: run
/**
* @inheritdoc
* @return string
* @throws InvalidConfigException
* @throws \yii\web\ServerErrorHttpException
*/
public function run()
{
parent::run();
if (null === $this->category_group_id) {
throw new InvalidConfigException("ProductsWidget.category_group_id should be set");
}
$products = Product::filteredProducts($this->category_group_id, $this->values_by_property_id, $this->selected_category_id, $this->force_sorting, $this->limit, false, $this->force_limit, $this->additional_filters);
return $this->render($this->viewFile, ['products' => $products, 'itemView' => $this->itemView, 'values_by_property_id' => $this->values_by_property_id, 'category_group_id' => $this->category_group_id, 'selected_category_id' => $this->selected_category_id]);
}
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:15,代码来源:ProductsWidget.php
示例10: 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]);
}
}
开发者ID:lzpfmh,项目名称:dotplant2,代码行数:9,代码来源:SearchProductsByDescriptionHandler.php
示例11: 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');
}
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:10,代码来源:Search.php
示例12: down
public function down()
{
$this->dropTable('{{%special_price_list_type}}');
$this->dropTable('{{%special_price_object}}');
$this->dropColumn('{{%special_price_list}}', 'type_id');
$this->addColumn('{{%special_price_list}}', 'type', "ENUM('core', 'discount', 'delivery', 'project') DEFAULT 'project'");
$this->update('{{%special_price_list}}', ['type' => 'core'], ['class' => 'app\\modules\\shop\\models\\Currency', 'object_id' => Object::getForClass(Product::className())->id]);
$this->update('{{%special_price_list}}', ['type' => 'discount'], ['class' => 'app\\modules\\shop\\models\\Discount', 'object_id' => Object::getForClass(Product::className())->id]);
$this->delete('{{%special_price_list}}', ['class' => 'app\\modules\\shop\\models\\Discount', 'object_id' => Object::getForClass(Order::className())->id]);
}
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:10,代码来源:m150519_120719_spetial_price_order.php
示例13: up
public function up()
{
// return false;
$this->addColumn('{{%special_price_list}}', 'handler', Schema::TYPE_STRING);
$this->update('{{%special_price_list}}', ['class' => 'app\\modules\\shop\\helpers\\PriceHandlers', 'handler' => 'getCurrencyPriceProduct'], ['class' => 'app\\modules\\shop\\models\\Currency', 'object_id' => \app\models\Object::getForClass(\app\modules\shop\models\Product::className())->id]);
$this->update('{{%special_price_list}}', ['class' => 'app\\modules\\shop\\helpers\\PriceHandlers', 'handler' => 'getDiscountPriceProduct'], ['class' => 'app\\modules\\shop\\models\\Discount', 'object_id' => \app\models\Object::getForClass(\app\modules\shop\models\Product::className())->id]);
$this->update('{{%special_price_list}}', ['class' => 'app\\modules\\shop\\helpers\\PriceHandlers', 'handler' => 'getDiscountPriceOrder'], ['class' => 'app\\modules\\shop\\models\\Discount', 'object_id' => \app\models\Object::getForClass(\app\modules\shop\models\Order::className())->id]);
$this->insert('{{%special_price_list}}', ['object_id' => \app\models\Object::getForClass(\app\modules\shop\models\Order::className())->id, 'class' => 'app\\modules\\shop\\helpers\\PriceHandlers', 'active' => 1, 'sort_order' => 12, 'handler' => 'getDeliveryPriceOrder', 'type_id' => (new \yii\db\Query())->select('id')->from('{{%special_price_list_type}}')->where(['key' => 'delivery'])->scalar()]);
$this->insert('{{%events}}', ['owner_class_name' => 'app\\modules\\shop\\ShopModule', 'event_name' => 'order_calculate', 'event_class_name' => 'app\\modules\\shop\\events\\OrderCalculateEvent', 'selector_prefix' => '', 'event_description' => '', 'documentation_link' => '']);
$eventId = $this->db->lastInsertID;
$this->insert('{{%event_handlers}}', ['event_id' => $eventId, 'sort_order' => 0, 'handler_class_name' => 'app\\modules\\shop\\helpers\\PriceHandlers', 'handler_function_name' => 'handleSaveDiscounts', 'is_active' => 1, 'non_deletable' => 0, 'triggering_type' => 'application_trigger']);
}
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:12,代码来源:m150522_085644_order_calculate_event.php
示例14: search
public function search($params)
{
$query = Product::find()->with('prices');
$dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => new \yii\data\Sort(['attributes' => ['name', 'id', 'available']])]);
$this->load($params);
if (!$this->validate()) {
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'available' => $this->available, 'producer_id' => $this->producer_id]);
$query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'text', $this->text])->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'short_text', $this->short_text])->andFilterWhere(['like', 'category_id', $this->category_id]);
return $dataProvider;
}
开发者ID:oakcms,项目名称:oakcms,代码行数:12,代码来源:ProductSearch.php
示例15: getData
public function getData()
{
if ($this->data === []) {
$event = new ModificationDataEvent();
$query = Product::find()->where(['active' => 1]);
foreach ($query->each() as $product) {
$event->model = $product;
$this->trigger(self::MODIFICATION_DATA, $event);
$this->data[] = $event->dataArray;
}
}
return $this->data;
}
开发者ID:lzpfmh,项目名称:dotplant2,代码行数:13,代码来源:GoogleMerchants.php
示例16: run
/**
* @return string
*/
public function run()
{
parent::run();
if (!$this->product instanceof Product) {
return '';
}
$cacheKey = 'RelatedProduct:' . implode('_', [$this->viewFile, $this->product, json_encode($this->additional)]);
if (false !== ($cache = \Yii::$app->cache->get($cacheKey))) {
return $cache;
}
$result = $this->render($this->viewFile, ['model' => $this->product, 'products' => $this->product->relatedProducts, 'additional' => $this->additional]);
\Yii::$app->cache->set($cacheKey, $result, 0, new TagDependency(['tags' => [ActiveRecordHelper::getObjectTag(Product::className(), $this->product->id), ActiveRecordHelper::getCommonTag(\app\modules\shop\models\RelatedProduct::className())]]));
return $result;
}
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:17,代码来源:RelatedProduct.php
示例17: run
public function run()
{
app\backend\assets\FrontendEditingAsset::register($this->view);
$items = [['label' => Icon::show('dashboard') . ' ' . Yii::t('app', 'Backend'), 'url' => ['/backend/']]];
switch (Yii::$app->requestedRoute) {
case 'shop/product/list':
if (isset($_GET['properties'])) {
$apply_if_params = [];
foreach ($_GET['properties'] as $property_id => $values) {
if (isset($values[0])) {
$apply_if_params[$property_id] = $values[0];
}
}
if (Yii::$app->response->dynamic_content_trait === true) {
$items[] = ['label' => Icon::show('puzzle') . ' ' . Yii::t('app', 'Edit Dynamic Content'), 'url' => ['/backend/dynamic-content/edit', 'id' => Yii::$app->response->matched_dynamic_content_trait_model->id]];
} else {
if (isset($_GET['properties'], $_GET['last_category_id'])) {
$items[] = ['label' => Icon::show('puzzle') . ' ' . Yii::t('app', 'Add Dynamic Content'), 'url' => ['/backend/dynamic-content/edit', 'DynamicContent' => ['apply_if_params' => Json::encode($apply_if_params), 'apply_if_last_category_id' => $_GET['last_category_id'], 'object_id' => Object::getForClass(app\modules\shop\models\Product::className())->id, 'route' => 'shop/product/list']]];
}
}
} else {
// no properties selected - go to category edit page
if (isset($_GET['last_category_id'])) {
$reviewsLink = $this->getReviewEditParams("Category", intval($_GET['last_category_id']));
$cat = app\modules\shop\models\Category::findById($_GET['last_category_id']);
$items[] = ['label' => Icon::show('pencil') . ' ' . Yii::t('app', 'Edit category'), 'url' => ['/shop/backend-category/edit', 'id' => $cat->id, 'parent_id' => $cat->parent_id]];
}
}
break;
case 'shop/product/show':
if (isset($_GET['model_id'])) {
$reviewsLink = $this->getReviewEditParams("Product", intval($_GET['model_id']));
$items[] = ['label' => Icon::show('pencil') . ' ' . Yii::t('app', 'Edit product'), 'url' => ['/shop/backend-product/edit', 'id' => intval($_GET['model_id'])]];
}
break;
case '/page/page/show':
case '/page/page/list':
if (isset($_GET['id'])) {
$page = app\modules\page\models\Page::findById($_GET['id']);
$reviewsLink = $this->getReviewEditParams("Page", $_GET['id']);
$items[] = ['label' => Icon::show('pencil') . ' ' . Yii::t('app', 'Edit page'), 'url' => ['/page/backend/edit', 'id' => $page->id, 'parent_id' => $page->parent_id]];
}
break;
}
if (!empty($reviewsLink)) {
$items[] = $reviewsLink;
}
return $this->render('floating-panel', ['items' => $items, 'bottom' => $this->bottom]);
}
开发者ID:lzpfmh,项目名称:dotplant2,代码行数:49,代码来源:FloatingPanel.php
示例18: editQuery
public static function editQuery(SearchEvent $event)
{
/** @var \app\modules\shop\ShopModule $module */
$module = \Yii::$app->modules['shop'];
/** @var \app\modules\shop\ShopModule $module */
$properties = (new Query())->select('`id`')->from(PropertyStaticValues::tableName())->where('`name` LIKE :q')->addParams([':q' => '%' . $event->q . '%'])->all();
$event->activeQuery->select('{{%object_static_values}}.object_model_id')->distinct(true)->from(ObjectStaticValues::tableName())->where('{{%object_static_values}}.object_id = :objectId')->addParams([':objectId' => Object::getForClass(Product::className())->id])->andWhere(['in', '{{%object_static_values}}.property_static_value_id', ArrayHelper::getColumn($properties, 'id')]);
if ($module->allowSearchGeneratedProducts != 1) {
$event->activeQuery->innerJoin('{{%product}}', '{{%product}}.id = {{%object_static_values}}.object_model_id');
$event->activeQuery->andWhere(['{{%product}}.parent_id' => 0, '{{%product}}.active' => 1]);
}
$event->setFunctionSearch(function ($activeQuery) {
return ArrayHelper::getColumn($activeQuery->all(), 'object_model_id');
});
}
开发者ID:lzpfmh,项目名称:dotplant2,代码行数:15,代码来源:SearchProductsByPropertyHandler.php
示例19: actionAutoCompleteSearch
/**
* @param $term
* @return string JSON
*/
public function actionAutoCompleteSearch($term)
{
Yii::$app->response->format = Response::FORMAT_JSON;
$query = Product::find()->select(['id', 'name', 'main_category_id', 'slug', 'sku'])->orderBy(['sort_order' => SORT_ASC, 'id' => SORT_DESC]);
foreach (['name', 'content', 'sku'] as $attribute) {
$query->orWhere(['like', $attribute, $term]);
}
$query->andWhere(['active' => 1]);
$products = $query->limit(Yii::$app->getModule('core')->autoCompleteResultsCount)->all();
$result = [];
foreach ($products as $product) {
/** @var Product $product */
$result[] = ['id' => $product->id, 'name' => $product->name, 'url' => Url::toRoute(['@product', 'model' => $product, 'category_group_id' => $product->getMainCategory()->category_group_id], true)];
}
return $result;
}
开发者ID:Jamshid90,项目名称:dotplant2,代码行数:20,代码来源:DefaultController.php
示例20: 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;
}
开发者ID:lzpfmh,项目名称:dotplant2,代码行数:23,代码来源:ProductPriceRangeFilter.php
注:本文中的app\modules\shop\models\Product类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论