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


PHP ProductCategory::getById方法代码示例

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


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

示例1: 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

示例2: 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

示例3: actionEdit

 public function actionEdit($id, $redirectUrl = null)
 {
     $productCategory = ProductCategory::getById(intval($id));
     $breadcrumbLinks = static::getDetailsAndEditBreadcrumbLinks();
     $breadcrumbLinks[] = StringUtil::getChoppedStringContent(strval($productCategory), 25);
     $view = new ProductCategoriesPageView(ProductDefaultViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $this->makeEditAndDetailsView($this->attemptToSaveModelFromPost($productCategory, $redirectUrl), 'Edit'), $breadcrumbLinks, 'ProductBreadCrumbView'));
     echo $view->render();
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:8,代码来源:CategoryController.php

示例4: testChildProductCategories

 public function testChildProductCategories()
 {
     $childProductCategory = new ProductCategory();
     $childProductCategory->name = "My Test Category Child";
     $existingCats = ProductCategory::getByName('My Test Category');
     $childProductCategory->productCategory = $existingCats[0];
     $this->assertTrue($childProductCategory->save());
     $id = $childProductCategory->id;
     unset($childProductCategory);
     $childProductCategory = ProductCategory::getById($id);
     $this->assertEquals("My Test Category Child", $childProductCategory->name);
     $this->assertEquals("My Test Category", $existingCats[0]->name);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:13,代码来源:ProductCategoryTest.php

示例5: testSuperUserDeleteAction

 public function testSuperUserDeleteAction()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     Yii::app()->user->userModel = $super;
     $productCategory = ProductCategoryTestHelper::createProductCategoryByName("My New Category");
     //Delete a product template
     $this->setGetArray(array('id' => $productCategory->id));
     $this->resetPostArray();
     $productCategories = ProductCategory::getAll();
     $this->assertEquals(14, count($productCategories));
     $this->runControllerWithRedirectExceptionAndGetContent('productTemplates/category/delete');
     $productCategories = ProductCategory::getAll();
     $this->assertEquals(13, count($productCategories));
     try {
         ProductCategory::getById($productCategory->id);
         $this->fail();
     } catch (NotFoundException $e) {
         //success
     }
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:20,代码来源:ProductCategorySuperUserWalkthroughTest.php


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