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


PHP ProductCategory类代码示例

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


在下文中一共展示了ProductCategory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testZeroPriceWithVariations

 public function testZeroPriceWithVariations()
 {
     Config::inst()->update('ProductCategory', 'must_have_price', true);
     $products = $this->electronics->ProductsShowable();
     $this->assertEquals(0, $products->count(), 'No product should be returned as there\'s no price set');
     // Create a variation for HDTV
     ProductVariation::create(array('InternalItemID' => '50-Inch', 'Price' => 1200, 'ProductID' => $this->hdtv->ID))->write();
     $products = $this->electronics->ProductsShowable();
     $this->assertDOSEquals(array(array('URLSegment' => 'hdtv')), $products, 'HDTV has a priced extension and should now show up in the list of products');
 }
开发者ID:burnbright,项目名称:silverstripe-shop,代码行数:10,代码来源:ProductCategoryTest.php

示例2: executeProductLink

 public function executeProductLink(sfWebRequest $request)
 {
     if ($request->hasParameter("categoryid") && $request->hasParameter("productid")) {
         $prodcat = new ProductCategory();
         $prodcat->setProductId($request->getParameter("productid"));
         $prodcat->setCategoryId($request->getParameter("categoryid"));
         $prodcat->save();
         cart::update_node($request->getParameter("categoryid"));
         return true;
     }
 }
开发者ID:richhl,项目名称:sfCartPlugin,代码行数:11,代码来源:actions.class.php

示例3: requireDefaultRecords

 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     $allCats = DataObject::get('ProductCategory');
     if (!$allCats->count()) {
         $cat = new ProductCategory();
         $cat->Title = 'Default';
         $cat->Code = 'DEFAULT';
         $cat->write();
     }
 }
开发者ID:helpfulrobot,项目名称:dynamic-foxystripe,代码行数:11,代码来源:ProductCategory.php

示例4: createProductCategory

 public static function createProductCategory($id = '')
 {
     $time = mt_rand();
     $name = 'SugarProductCategory';
     $product = new ProductCategory();
     $product->name = $name . $time;
     if (!empty($id)) {
         $product->new_with_id = true;
         $product->id = $id;
     }
     $product->save();
     self::$_createdProductCategories[] = $product;
     return $product;
 }
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:14,代码来源:SugarTestProductCategoryUtilities.php

示例5: createProductCategoryByName

 public static function createProductCategoryByName($name, $parentCategory = null)
 {
     $productCategory = new ProductCategory();
     $productCategory->name = $name;
     $productCatalog = new ProductCatalog();
     $productCatalog->name = ProductCatalog::DEFAULT_NAME;
     $productCatalog->save();
     $productCategory->productCatalogs->add($productCatalog);
     $saved = $productCategory->save();
     if ($parentCategory != null) {
         $productCategory->productCategories->add($parentCategory);
     }
     assert('$saved');
     return $productCategory;
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:15,代码来源:ProductCategoryTestHelper.php

示例6: actions

 public function actions()
 {
     $formSettings = array('redirect' => $this->createUrl('admin'), 'forms' => array('id' => 'mainForm', 'varName' => 'productCategory', 'models' => 'ProductCategory', 'onAfterSave' => function ($event) {
         $model = $event->params['model'];
         if ($model->location != 'nochange') {
             $decode = CJSON::decode($_POST['ProductCategory']['location']);
             $to = ProductCategory::model()->findByPk((int) $decode['to']);
             $action = $decode['action'];
             switch ($action) {
                 case 'child':
                     $model->moveAsLast($to);
                     break;
                 case 'before':
                     if ($to->isRoot()) {
                         $model->moveAsRoot();
                     } else {
                         $model->moveBefore($to);
                     }
                     break;
                 case 'after':
                     if ($to->isRoot()) {
                         $model->moveAsRoot();
                     } else {
                         $model->moveAfter($to);
                     }
                     break;
             }
         }
     }));
     return array('create' => array('class' => 'application.components.actions.Create', 'formSettings' => $formSettings), 'update' => array('class' => 'application.components.actions.Update', 'formSettings' => $formSettings), 'delete' => array('class' => 'application.components.actions.Delete', 'modelClass' => 'ProductCategory'), 'admin' => array('class' => 'application.components.actions.Admin', 'modelClass' => 'ProductCategory'));
 }
开发者ID:kostya1017,项目名称:our,代码行数:31,代码来源:AdmincategoryController.php

示例7: __construct

 public function __construct($controller, $name)
 {
     $product = new Product();
     $title = new TextField('Title', _t('Product.PAGETITLE', 'Product Title'));
     $urlSegment = new TextField('URLSegment', 'URL Segment');
     $menuTitle = new TextField('MenuTitle', 'Navigation Title');
     $sku = TextField::create('InternalItemID', _t('Product.CODE', 'Product Code/SKU'), '', 30);
     $categories = DropdownField::create('ParentID', _t("Product.CATEGORY", "Category"), $product->categoryoptions())->setDescription(_t("Product.CATEGORYDESCRIPTION", "This is the parent page or default category."));
     $otherCategories = ListBoxField::create('ProductCategories', _t("Product.ADDITIONALCATEGORIES", "Additional Categories"), ProductCategory::get()->filter("ID:not", $product->getAncestors()->map('ID', 'ID'))->map('ID', 'NestedTitle')->toArray())->setMultiple(true);
     $model = TextField::create('Model', _t('Product.MODEL', 'Model'), '', 30);
     $featured = CheckboxField::create('Featured', _t('Product.FEATURED', 'Featured Product'));
     $allow_purchase = CheckboxField::create('AllowPurchase', _t('Product.ALLOWPURCHASE', 'Allow product to be purchased'), 1, 'Content');
     $price = TextField::create('BasePrice', _t('Product.PRICE', 'Price'))->setDescription(_t('Product.PRICEDESC', "Base price to sell this product at."))->setMaxLength(12);
     $image = UploadField::create('Image', _t('Product.IMAGE', 'Product Image'));
     $content = new HtmlEditorField('Content', 'Content');
     $fields = new FieldList();
     $fields->add($title);
     //$fields->add($urlSegment);
     //$fields->add($menuTitle);
     //$fields->add($sku);
     $fields->add($categories);
     //$fields->add($otherCategories);
     $fields->add($model);
     $fields->add($featured);
     $fields->add($allow_purchase);
     $fields->add($price);
     $fields->add($image);
     $fields->add($content);
     //$fields = $product->getFrontEndFields();
     $actions = new FieldList(new FormAction('submit', _t("ChefProductForm.ADDPRODUCT", 'Add product')));
     $requiredFields = new RequiredFields(array('Title', 'Model', 'Price'));
     parent::__construct($controller, $name, $fields, $actions, $requiredFields);
 }
开发者ID:8secs,项目名称:cocina,代码行数:33,代码来源:ChefProductForm.php

示例8: testLoad

 public function testLoad()
 {
     $this->assertEquals(2, Group::getCount());
     $this->assertEquals(0, Role::getCount());
     $this->assertEquals(0, Account::getCount());
     $this->assertEquals(0, Contact::getCount());
     $this->assertEquals(0, Opportunity::getCount());
     $this->assertEquals(0, Meeting::getCount());
     $this->assertEquals(0, Note::getCount());
     $this->assertEquals(0, Task::getCount());
     $this->assertEquals(1, User::getCount());
     $this->assertEquals(0, ProductCatalog::getCount());
     $this->assertEquals(0, ProductCategory::getCount());
     $this->assertEquals(0, ProductTemplate::getCount());
     $this->assertEquals(0, Product::getCount());
     $messageLogger = new MessageLogger();
     DemoDataUtil::unsetLoadedModules();
     DemoDataUtil::load($messageLogger, 3);
     $this->assertEquals(8, Group::getCount());
     $this->assertEquals(3, Role::getCount());
     $this->assertEquals(3, Account::getCount());
     $this->assertEquals(16, Contact::getCount());
     $this->assertEquals(6, Opportunity::getCount());
     $this->assertEquals(18, Meeting::getCount());
     $this->assertEquals(12, Note::getCount());
     $this->assertEquals(9, Task::getCount());
     $this->assertEquals(10, User::getCount());
     $this->assertEquals(1, ProductCatalog::getCount());
     $this->assertEquals(6, ProductCategory::getCount());
     $this->assertEquals(32, ProductTemplate::getCount());
     $this->assertEquals(59, Product::getCount());
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:32,代码来源:DemoDataUtilTest.php

示例9: populateModelData

 /**
  * Populate Product Template Model with data
  * @param Product Template object $model
  * @param int $counter
  */
 public function populateModelData(&$model, $counter)
 {
     assert('$model instanceof ProductTemplate');
     parent::populateModel($model);
     $productTemplateRandomData = self::getProductTemplatesRandomData();
     $name = $productTemplateRandomData['names'][$counter];
     $productCategoryName = self::getProductCategoryForTemplate($name);
     $allCats = ProductCategory::getAll();
     foreach ($allCats as $category) {
         if ($category->name == $productCategoryName) {
             $categoryId = $category->id;
         }
     }
     $productCategory = ProductCategory::getById($categoryId);
     $model->name = $name;
     $model->productCategories->add($productCategory);
     $model->priceFrequency = 2;
     $model->cost->value = 200;
     $model->listPrice->value = 200;
     $model->sellPrice->value = 200;
     $model->status = ProductTemplate::STATUS_ACTIVE;
     $model->type = ProductTemplate::TYPE_PRODUCT;
     $sellPriceFormula = new SellPriceFormula();
     $sellPriceFormula->type = SellPriceFormula::TYPE_EDITABLE;
     $model->sellPriceFormula = $sellPriceFormula;
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:31,代码来源:ProductTemplatesDemoDataMaker.php

示例10: screen

 public function screen()
 {
     $status = 'available';
     if (!is_dir($this->theme_path)) {
         $status = 'directory';
     } else {
         if (!is_writable($this->theme_path)) {
             $status = 'permissions';
         } else {
             $builtin = array_filter(scandir($this->template_path), 'filter_dotfiles');
             $theme = array_filter(scandir($this->theme_path), 'filter_dotfiles');
             if (empty($theme)) {
                 $status = 'ready';
             } elseif (array_diff($builtin, $theme)) {
                 $status = 'incomplete';
             }
         }
     }
     $category_views = array('grid' => Shopp::__('Grid'), 'list' => Shopp::__('List'));
     $row_products = array(2, 3, 4, 5, 6, 7);
     $productOrderOptions = ProductCategory::sortoptions();
     $productOrderOptions['custom'] = Shopp::__('Custom');
     $orderOptions = array('ASC' => Shopp::__('Order'), 'DESC' => Shopp::__('Reverse Order'), 'RAND' => Shopp::__('Shuffle'));
     $orderBy = array('sortorder' => Shopp::__('Custom arrangement'), 'created' => Shopp::__('Upload date'));
     include $this->ui('presentation.php');
 }
开发者ID:forthrobot,项目名称:inuvik,代码行数:26,代码来源:Presentation.php

示例11: getDefaultSearchContext

 public function getDefaultSearchContext()
 {
     $context = parent::getDefaultSearchContext();
     $fields = $context->getFields();
     $fields->push(CheckboxField::create("HasBeenUsed"));
     //add date range filtering
     $fields->push(ToggleCompositeField::create("StartDate", "Start Date", array(DateField::create("q[StartDateFrom]", "From")->setConfig('showcalendar', true), DateField::create("q[StartDateTo]", "To")->setConfig('showcalendar', true))));
     $fields->push(ToggleCompositeField::create("EndDate", "End Date", array(DateField::create("q[EndDateFrom]", "From")->setConfig('showcalendar', true), DateField::create("q[EndDateTo]", "To")->setConfig('showcalendar', true))));
     //must be enabled in config, because some sites may have many products = slow load time, or memory maxes out
     //future solution is using an ajaxified field
     if (self::config()->filter_by_product) {
         $fields->push(ListboxField::create("Products", "Products", Product::get()->map()->toArray())->setMultiple(true));
     }
     if (self::config()->filter_by_category) {
         $fields->push(ListboxField::create("Categories", "Categories", ProductCategory::get()->map()->toArray())->setMultiple(true));
     }
     if ($field = $fields->fieldByName("Code")) {
         $field->setDescription("This can be a partial match.");
     }
     //get the array, to maniplulate name, and fullname seperately
     $filters = $context->getFilters();
     $filters['StartDateFrom'] = GreaterThanOrEqualFilter::create('StartDate');
     $filters['StartDateTo'] = LessThanOrEqualFilter::create('StartDate');
     $filters['EndDateFrom'] = GreaterThanOrEqualFilter::create('EndDate');
     $filters['EndDateTo'] = LessThanOrEqualFilter::create('EndDate');
     $context->setFilters($filters);
     return $context;
 }
开发者ID:helpfulrobot,项目名称:silvershop-discounts,代码行数:28,代码来源:Discount.php

示例12: getListItems

 /**
  * getListItems - Phương thức dùng để lấy dữ liệu
  */
 public function getListItems($category_id = null)
 {
     Yii::import('application.modules.products.models.ProductItem');
     $model = new ProductItem('search');
     $model->unsetAttributes();
     $criteria = new CDbCriteria();
     $criteria->order = 'created DESC';
     if ($category_id) {
         Yii::import('application.modules.products.models.ProductCategory');
         $categories = ProductCategory::model()->findByPk($category_id);
         if (!$categories) {
             return null;
         }
         $this->__category = $categories;
         $descendants = $categories->descendants()->findAll('is_active = 1');
         $arrCat = array($category_id);
         foreach ($descendants as $cat) {
             $arrCat[] = $cat->id;
         }
         $criteria->with = array('categoryitem');
         $criteria->together = true;
         foreach ($arrCat as $cat) {
             $criteria->compare('categoryitem.category_id', $cat, false, 'OR');
         }
     }
     $criteria->compare('status', 1);
     $search = new CActiveDataProvider($model, array('criteria' => $criteria, 'pagination' => array('pageSize' => Yii::app()->getModule('products')->entriesShow)));
     $data = $search->getData();
     $this->__pagination = $search->pagination;
     return $data;
 }
开发者ID:qkongvan,项目名称:k6-thuc-pham,代码行数:34,代码来源:ProductItemsWidget.php

示例13: resolveProductTemplateHasManyProductCategoriesFromPost

 /**
  * Resolve the product categories from prost
  * @param ProductTemplate $productTemplate
  * @param array $postData
  * @return array
  */
 public static function resolveProductTemplateHasManyProductCategoriesFromPost(ProductTemplate $productTemplate, $postData)
 {
     $newCategory = array();
     if (isset($postData['categoryIds']) && strlen($postData['categoryIds']) > 0) {
         $categoryIds = explode(",", $postData['categoryIds']);
         // Not Coding Standard
         foreach ($categoryIds as $categoryId) {
             $newCategory[$categoryId] = ProductCategory::getById((int) $categoryId);
         }
         if ($productTemplate->productCategories->count() > 0) {
             $categoriesToRemove = array();
             foreach ($productTemplate->productCategories as $index => $existingCategory) {
                 $categoriesToRemove[] = $existingCategory;
             }
             foreach ($categoriesToRemove as $categoryToRemove) {
                 $productTemplate->productCategories->remove($categoryToRemove);
             }
         }
         //Now add missing categories
         foreach ($newCategory as $category) {
             $productTemplate->productCategories->add($category);
         }
     } else {
         //remove all categories
         $productTemplate->productCategories->removeAll();
     }
     return $newCategory;
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:34,代码来源:ProductTemplateProductCategoriesUtil.php

示例14: run

 public function run()
 {
     $categoriesTree = ProductCategory::model()->getTree();
     $currentCategory = Yii::app()->daShop->currentIdCategory !== null ? $categoriesTree->getById(Yii::app()->daShop->currentIdCategory) : null;
     $tree = array('items' => $this->buildTree($categoriesTree, $currentCategory));
     $this->render('categoryWidget', compact('tree'));
 }
开发者ID:kot-ezhva,项目名称:ygin,代码行数:7,代码来源:CategoryWidget.php

示例15: addmodels

 public function addmodels($id)
 {
     if ($this->isAdminRequest()) {
         //$id = $_POST['id'];
         // print_r($_POST);
         $rules = array('models' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         // process the login
         if ($validator->fails()) {
             return Redirect::to('admin/products/' . $id . '/models')->withErrors($validator)->with('productcategory', ProductCategory::find($id))->with('models', Products::where('product_category_id', '=', $id)->get())->withInput(Input::all());
         } else {
             $models = Input::get('models');
             $models_arr = explode(",", $models);
             foreach ($models_arr as $model) {
                 $product_model = new Products();
                 $product_model->model_id = $model;
                 $product_model->product_category_id = $id;
                 $product_model->save();
             }
             // // redirect
             Session::flash('message', 'Successfully added models.');
             return Redirect::to('admin/products/' . $id . '/models');
         }
         //$import = importmodels('boo');
         //
         // $productcategory = ProductCategory::find($id);
         // $models = Products::where('product_category_id','=',$id)->get();
         // return View::make('admin.products.models')
         //     ->with('productcategory',$productcategory)
         //     ->with('models',$models);
         // }
     }
 }
开发者ID:periodthree,项目名称:mhd,代码行数:33,代码来源:ProductsController.php


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