当前位置: 首页>>代码示例>>PHP>>正文


PHP models\Product类代码示例

本文整理汇总了PHP中app\modules\shop\models\Product的典型用法代码示例。如果您正苦于以下问题:PHP Product类的具体用法?PHP Product怎么用?PHP Product使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Product类的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');
 }
开发者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


注:本文中的app\modules\shop\models\Product类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。