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


PHP Category::getInstanceByID方法代码示例

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


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

示例1: delete

 public function delete()
 {
     $product = Product::getInstanceByID($this->request->get('id'), ActiveRecord::LOAD_DATA, array('Category'));
     $category = Category::getInstanceByID($this->request->get('categoryId'), ActiveRecord::LOAD_DATA);
     $relation = ActiveRecordModel::getInstanceById('ProductCategory', array('productID' => $product->getID(), 'categoryID' => $category->getID()));
     $relation->delete();
     return new JSONResponse(array('data' => $relation->toFlatArray()));
 }
开发者ID:saiber,项目名称:livecart,代码行数:8,代码来源:ProductCategoryController.php

示例2: saveCategories

 public function saveCategories()
 {
     $store = $this->getStore();
     if ('nochange' != $this->request->get('categories')) {
         $store->deleteRelatedRecordSet('ClonedStoreCategory');
         foreach (explode(',', $this->request->get('categories')) as $cat) {
             ClonedStoreCategory::getNewInstance(Category::getInstanceByID($cat), $store)->save();
         }
     }
     return new JSONResponse(null, 'success', 'Store category settings saved successfully');
 }
开发者ID:saiber,项目名称:www,代码行数:11,代码来源:ClonedStoreController.php

示例3: create

 public function create()
 {
     $parentId = $this->request->get('parentID', false);
     if (substr($parentId, 0, 1) == 'c') {
         $parent = Category::getInstanceByID(substr($parentId, 1));
     } else {
         $parent = Product::getInstanceByID($parentId);
     }
     $productOption = ProductOption::getNewInstance($parent);
     return $this->save($productOption);
 }
开发者ID:GregerA,项目名称:livecart,代码行数:11,代码来源:ProductOptionController.php

示例4: save

 /**
  * @role update
  */
 public function save()
 {
     $validator = $this->buildValidator();
     if (!$validator->isValid()) {
         return new JSONResponse(array('err' => $validator->getErrorList()));
     }
     $post = $this->request->get('id') ? ActiveRecordModel::getInstanceById('ProductRatingType', $this->request->get('id'), ActiveRecordModel::LOAD_DATA) : ProductRatingType::getNewInstance(Category::getInstanceByID($this->request->get('categoryId'), Category::LOAD_DATA));
     $post->loadRequestData($this->request);
     $post->save();
     return new JSONResponse($post->toArray());
 }
开发者ID:saiber,项目名称:livecart,代码行数:14,代码来源:RatingTypeController.php

示例5: addCategory

 public function addCategory()
 {
     $category = Category::getInstanceByID($this->request->get('id'), ActiveRecord::LOAD_DATA, array('Category'));
     $relatedCategory = Category::getInstanceByID($this->request->get('categoryId'), ActiveRecord::LOAD_DATA);
     // check if the category is not assigned to this category already
     $f = select(eq('CategoryRelationship.relatedCategoryID', $relatedCategory->getID()));
     if ($category->getRelatedRecordSet('CategoryRelationship', $f)->size()) {
         return new JSONResponse(false, 'failure', $this->translate('_err_already_assigned'));
     }
     $relation = CategoryRelationship::getNewInstance($category, $relatedCategory);
     $relation->save();
     $relatedCategory->getPathNodeSet();
     return new JSONResponse(array('data' => $relation->toFlatArray()));
 }
开发者ID:saiber,项目名称:livecart,代码行数:14,代码来源:CategoryRelationshipController.php

示例6: _testStringSerialize

 private function _testStringSerialize($string, $equals = true)
 {
     error_reporting(E_WARNING);
     $root = Category::getInstanceByID(1);
     $new = Category::getNewInstance($root);
     $new->setValueByLang('name', 'en', $string);
     $new->save();
     ActiveRecordModel::clearPool();
     $restored = Category::getInstanceByID($new->getID(), Category::LOAD_DATA);
     if ($equals) {
         $this->assertEqual($string, $restored->getValueByLang('name', 'en'));
     } else {
         $this->assertNotEquals($string, $restored->getValueByLang('name', 'en'));
     }
     error_reporting(E_ALL);
 }
开发者ID:saiber,项目名称:livecart,代码行数:16,代码来源:MultiLingualObjectTest.php

示例7: index

 public function index()
 {
     $categoryID = (int) $this->request->get('id');
     $category = Category::getInstanceByID($categoryID, ActiveRecord::LOAD_DATA);
     // get lists
     $f = new ARSelectFilter();
     $f->setOrder(new ARFieldHandle('ProductList', 'position'));
     $lists = $category->getRelatedRecordSetArray('ProductList', $f);
     $ids = array();
     foreach ($lists as $list) {
         $ids[] = $list['ID'];
     }
     // get list items
     $f = new ARSelectFilter(new INCond(new ARFieldHandle('ProductListItem', 'productListID'), $ids));
     $f->setOrder(new ARFieldHandle('ProductList', 'position'));
     $f->setOrder(new ARFieldHandle('ProductListItem', 'productListID'));
     $f->setOrder(new ARFieldHandle('ProductListItem', 'position'));
     $items = ActiveRecordModel::getRecordSetArray('ProductListItem', $f, array('ProductList', 'Product', 'ProductImage'));
     $items = ActiveRecordGroup::mergeGroupsWithFields('ProductList', $lists, $items);
     $response = new ActionResponse();
     $response->set('ownerID', $categoryID);
     $response->set('items', $items);
     return $response;
 }
开发者ID:saiber,项目名称:livecart,代码行数:24,代码来源:ProductListController.php

示例8: _getCategoryById

 private function _getCategoryById($id, $includeRootNode = false)
 {
     if ($includeRootNode == false && $id == $this->root->getID()) {
         throw new Exception('Cannot change root level category.');
     }
     $category = Category::getInstanceByID($id, true);
     // if id is not integer getInstanceByID() will not throw exception?
     // could remove next 3 lines, if all ID come from ModelApi::getRequestID(), but they not (parent node id, for example)
     if (false == $category->getID() > 0) {
         throw new Exception('Bad ID field value.');
     }
     return $category;
 }
开发者ID:saiber,项目名称:www,代码行数:13,代码来源:CategoryApi.php

示例9: getCategoryByPath

 private function getCategoryByPath($profile, $names)
 {
     if (!is_array($names)) {
         $names = explode(' / ', $names);
     }
     $hash = '';
     $hashRoot = $this->getRoot($profile)->getID();
     $cat = null;
     foreach ($names as $name) {
         $hash .= "\n" . $name;
         if (!isset($this->categories[$hash])) {
             $f = Category::getInstanceByID($hashRoot)->getSubcategoryFilter();
             $f->mergeCondition(new EqualsCond(MultiLingualObject::getLangSearchHandle(new ARFieldHandle('Category', 'name'), $this->application->getDefaultLanguageCode()), $name));
             $cat = ActiveRecordModel::getRecordSet('Category', $f)->get(0);
             if (!$cat) {
                 $cat = Category::getNewInstance(Category::getInstanceByID($hashRoot));
                 $cat->isEnabled->set(true);
                 $cat->setValueByLang('name', $this->application->getDefaultLanguageCode(), $name);
                 $cat->save();
             }
             $this->categories[$hash] = $cat->getID();
         }
         $hashRoot = $this->categories[$hash];
         $cat = Category::getInstanceByID($hashRoot, true);
     }
     return $cat;
 }
开发者ID:GregerA,项目名称:livecart,代码行数:27,代码来源:ProductImport.php

示例10: xmlRecursivePath

 public function xmlRecursivePath()
 {
     $xmlResponse = new XMLResponse();
     $targetID = (int) $this->request->get("id");
     try {
         $categoriesList = Category::getInstanceByID($targetID)->getPathBranchesArray();
         if (count($categoriesList) > 0 && isset($categoriesList['children'][0]['parent'])) {
             $xmlResponse->set("rootID", $categoriesList['children'][0]['parent']);
             $xmlResponse->set("categoryList", $categoriesList);
         }
         $xmlResponse->set("doNotTouch", $this->request->get("doNotTouch"));
     } catch (Exception $e) {
     }
     $xmlResponse->set("targetID", $targetID);
     return $xmlResponse;
 }
开发者ID:GregerA,项目名称:livecart,代码行数:16,代码来源:CategoryController.php

示例11: __construct

 public function __construct()
 {
     parent::__construct('Product files tests');
     $this->tmpFilePath = ClassLoader::getRealPath('cache.') . 'somefile.txt';
     $this->rootCategory = Category::getInstanceByID(Category::ROOT_ID);
 }
开发者ID:saiber,项目名称:livecart,代码行数:6,代码来源:ProductFileTest.php

示例12: boxRootCategoryBlock

 protected function boxRootCategoryBlock()
 {
     $rootID = $this->config->get('CAT_MENU_TOP_ROOT');
     $f = new ARSelectFilter(new EqualsCond(new ARFieldHandle('Category', 'isEnabled'), true));
     $categories = ActiveRecordModel::getRecordSetArray('Category', Category::getInstanceByID($rootID, true)->getBranchFilter($f));
     $tree = array($rootID => array('subCategories' => array()));
     foreach ($categories as $key => &$category) {
         $tree[$category['ID']] =& $category;
     }
     foreach ($categories as &$category) {
         $tree[$category['parentNodeID']]['subCategories'][] =& $category;
     }
     $tree = $tree[$rootID]['subCategories'];
     $response = new BlockResponse('categories', $tree);
     $path = $this->getCategory()->getPathNodeArray();
     if ($path) {
         $response->set('topCategoryId', $path[0]['ID']);
     }
     $response->set('currentId', $this->getCategory()->getID());
     $response->set('currentCategory', $this->getCategory()->toArray());
     return $response;
 }
开发者ID:saiber,项目名称:www,代码行数:22,代码来源:FrontendController.php

示例13: getSelectFilter

 protected function getSelectFilter()
 {
     $id = $this->getID();
     if ($this->isCategory()) {
         $owner = Category::getInstanceByID($id, Category::LOAD_DATA);
         $cond = new EqualsOrMoreCond(new ARFieldHandle('Category', 'lft'), $owner->lft->get());
         $cond->addAND(new EqualsOrLessCond(new ARFieldHandle('Category', 'rgt'), $owner->rgt->get()));
     } else {
         $cond = new EqualsCond(new ARFieldHandle('ProductReview', 'productID'), $id);
     }
     return new ARSelectFilter($cond);
 }
开发者ID:saiber,项目名称:livecart,代码行数:12,代码来源:ReviewController.php

示例14: create

 /**
  * @role create
  */
 public function create()
 {
     $product = Product::getNewInstance(Category::getInstanceByID($this->request->get('categoryID')), $this->translate('_new_product'));
     $response = $this->save($product);
     if ($response instanceof ActionResponse) {
         $response->get('productForm')->clearData();
         $response->set('id', $product->getID());
         return $response;
     } else {
         return $response;
     }
 }
开发者ID:saiber,项目名称:www,代码行数:15,代码来源:ProductController.php

示例15: __construct

 public function __construct()
 {
     parent::__construct('Related product tests');
     $this->rootCategory = Category::getInstanceByID(Category::ROOT_ID);
 }
开发者ID:saiber,项目名称:livecart,代码行数:5,代码来源:ProductRelationshipTest.php


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