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


PHP Category::recalculateProductsCount方法代码示例

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


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

示例1: __construct

 public function __construct(LiveCart $application, $database)
 {
     ini_set('memory_limit', '1700M');
     set_time_limit(0);
     error_reporting(E_ALL);
     ini_set('display_errors', 'On');
     Category::reindex();
     Category::recalculateProductsCount();
     $this->flush(__LINE__);
     $this->application = $application;
     $this->database = $database;
     $this->dbLogin = $this->getDBLogin();
     $this->importDatabase = $database . '_import';
     $this->flush(__LINE__);
     $this->timestamp = new ARSerializableDateTime(array_pop(array_pop(ActiveRecordModel::getDataBySQL('SELECT NOW()'))));
     $this->createSnapshot();
     $this->flush(__LINE__);
     foreach (ActiveRecordModel::getDataBySQL('SHOW TABLES IN ' . $database) as $table) {
         $table = array_shift($table);
         if (!in_array($table, self::$ignoredTables)) {
             $this->tables[] = $table;
         }
     }
     $this->flush(__LINE__);
 }
开发者ID:saiber,项目名称:www,代码行数:25,代码来源:ClonedStoreUpdater.php

示例2: saveMainCategory

 public function saveMainCategory()
 {
     $product = Product::getInstanceByID($this->request->get('id'), ActiveRecord::LOAD_DATA, array('Category'));
     $category = Category::getInstanceByID($this->request->get('categoryId'), ActiveRecord::LOAD_DATA);
     $product->category->set($category);
     $product->save();
     Category::recalculateProductsCount();
     return new RawResponse($category->getID());
 }
开发者ID:saiber,项目名称:livecart,代码行数:9,代码来源:ProductCategoryController.php

示例3: testCountRecalculate

 public function testCountRecalculate()
 {
     $this->root->totalProductCount->set(0);
     $this->categories[1]->totalProductCount->set(0);
     $this->categories[2]->totalProductCount->set(0);
     Category::recalculateProductsCount();
     $this->reloadCategories();
     $this->assertEquals(1, $this->categories[1]->totalProductCount->get());
     $this->assertEquals(1, $this->categories[2]->totalProductCount->get());
     $this->assertEquals(1, $this->root->totalProductCount->get());
 }
开发者ID:saiber,项目名称:livecart,代码行数:11,代码来源:ProductCategoryTest.php

示例4: import

 public function import()
 {
     $this->application->setDevMode(true);
     ignore_user_abort(true);
     ini_set('memory_limit', '512M');
     set_time_limit(0);
     if ($this->request->get('password') != $this->config->get('CLONE_STORE_API_KEY')) {
         return new RawResponse('Wrong password');
     }
     ActiveRecordModel::executeUpdate('SET FOREIGN_KEY_CHECKS=0;');
     ActiveRecord::getLogger()->setLogFileName(null);
     $dir = $this->getFileDir();
     //if (ob_get_length())
     //{
     ob_flush();
     ob_end_clean();
     //}
     //echo str_repeat('FLUSH ', 10000);
     foreach (scandir($dir) as $file) {
         if (strlen($file) < 3) {
             continue;
         }
         $path = $dir . $file;
         if (substr($file, -4) == '.sql') {
             $f = fopen($path, 'r');
             $prev = '';
             while (!feof($f)) {
                 $s = $prev . fread($f, 1024 * 1024);
                 if (!feof($f)) {
                     $pos = strrpos($s, ";\n");
                     $prev = substr($s, $pos + 1);
                     $s = substr($s, 0, $pos);
                 }
                 Installer::loadDatabaseDump($s, true);
             }
         } else {
             $this->untar($path, ClassLoader::getRealPath('public.upload.'));
         }
         unlink($path);
     }
     $this->user->allowBackendAccess();
     $c = new ProductImageController($this->application);
     $c->resizeImages();
     Category::reindex();
     Category::recalculateProductsCount();
 }
开发者ID:saiber,项目名称:www,代码行数:46,代码来源:StoreSyncController.php

示例5: error_reporting

<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
include '../application/Initialize.php';
ClassLoader::import('application.LiveCart');
new LiveCart();
ClassLoader::import('application.model.category.Category');
Category::getInstanceById(1);
Category::recalculateProductsCount();
开发者ID:saiber,项目名称:www,代码行数:10,代码来源:FixCategoryCounts.php

示例6: processMass

 /**
  * @role mass
  */
 public function processMass()
 {
     $filter = $this->getSelectFilter();
     $act = $this->request->get('act');
     $field = array_pop(explode('_', $act, 2));
     if ('move' == $act) {
         new ActiveGrid($this->application, $filter, $this->getClassName());
         $cat = Category::getInstanceById($this->request->get('categoryID'), Category::LOAD_DATA);
         $update = new ARUpdateFilter();
         $update->setCondition($filter->getCondition());
         $update->addModifier('Product.categoryID', $cat->getID());
         $update->joinTable('ProductPrice', 'Product', 'productID AND (ProductPrice.currencyID = "' . $this->application->getDefaultCurrencyCode() . '")', 'ID');
         ActiveRecord::beginTransaction();
         ActiveRecord::updateRecordSet('Product', $update, Product::LOAD_REFERENCES);
         Category::recalculateProductsCount();
         ActiveRecord::commit();
         return new JSONResponse(array('act' => $this->request->get('act')), 'success', $this->translate('_move_succeeded'));
     }
     // remove design themes
     if ('theme' == $act && !$this->request->get('theme')) {
         ClassLoader::import('application.model.presentation.CategoryPresentation');
         ActiveRecord::deleteRecordSet('CategoryPresentation', new ARDeleteFilter($filter->getCondition()), null, array('Product', 'Category'));
         return new JSONResponse(array('act' => $this->request->get('act')), 'success', $this->translate('_themes_removed'));
     }
     $params = array();
     if ('manufacturer' == $act) {
         $params['manufacturer'] = Manufacturer::getInstanceByName($this->request->get('manufacturer'));
     } else {
         if ('price' == $act || 'inc_price' == $act) {
             $params['baseCurrency'] = $this->application->getDefaultCurrencyCode();
             $params['price'] = $this->request->get($act);
             $params['currencies'] = $this->application->getCurrencySet();
             $params['inc_price_value'] = $this->request->get('inc_price_value');
             $params['inc_quant_price'] = $this->request->get('inc_quant_price');
         } else {
             if ('addRelated' == $act) {
                 $params['relatedProduct'] = Product::getInstanceBySKU($this->request->get('related'));
                 if (!$params['relatedProduct']) {
                     return new JSONResponse(0);
                 }
             } else {
                 if ($this->request->get('categoryID')) {
                     $params['category'] = Category::getInstanceById($this->request->get('categoryID'), Category::LOAD_DATA);
                 } else {
                     if ('theme' == $act) {
                         ClassLoader::import('application.model.presentation.CategoryPresentation');
                         $params['theme'] = $this->request->get('theme');
                     } else {
                         if ('shippingClass' == $act) {
                             $params['shippingClass'] = $this->request->get('shippingClass');
                         } else {
                             if ('taxClass' == $act) {
                                 $params['taxClass'] = $this->request->get('taxClass');
                             }
                         }
                     }
                 }
             }
         }
     }
     $response = parent::processMass($params);
     if ($this->request->get('categoryID')) {
         Category::recalculateProductsCount();
     }
     return $response;
 }
开发者ID:saiber,项目名称:www,代码行数:69,代码来源:ProductController.php

示例7: afterImport

 public function afterImport()
 {
     Category::recalculateProductsCount();
 }
开发者ID:GregerA,项目名称:livecart,代码行数:4,代码来源:ProductImport.php

示例8: reorder

 /**
  * Reorder category node
  *
  * @role !category.sort
  */
 public function reorder()
 {
     $targetNode = Category::getInstanceByID((int) $this->request->get("id"));
     $parentNode = Category::getInstanceByID((int) $this->request->get("parentId"));
     try {
         if ($direction = $this->request->get("direction", false)) {
             if (ActiveTreeNode::DIRECTION_LEFT == $direction) {
                 $targetNode->moveLeft(false);
             }
             if (ActiveTreeNode::DIRECTION_RIGHT == $direction) {
                 $targetNode->moveRight(false);
             }
         } else {
             $targetNode->moveTo($parentNode);
         }
         Category::reindex();
         Category::recalculateProductsCount();
         return new JSONResponse(false, 'success', $this->translate('_categories_tree_was_reordered'));
     } catch (Exception $e) {
         return new JSONResponse(false, 'failure', $this->translate('_unable_to_reorder_categories_tree'));
     }
     return new JSONResponse($status);
 }
开发者ID:GregerA,项目名称:livecart,代码行数:28,代码来源:CategoryController.php

示例9: testDiscountByAdditionalCategories

 public function testDiscountByAdditionalCategories()
 {
     $product = $this->products[1];
     $condition = DiscountCondition::getNewInstance();
     $condition->isEnabled->set(true);
     $condition->save();
     $actionCondition = DiscountCondition::getNewInstance();
     $actionCondition->isEnabled->set(true);
     $actionCondition->conditionClass->set('RuleConditionContainsProduct');
     $actionCondition->save();
     $action = DiscountAction::getNewInstance($condition);
     $action->actionCondition->set($actionCondition);
     $action->isEnabled->set(true);
     $action->type->set(DiscountAction::TYPE_ITEM_DISCOUNT);
     $action->amount->set(10);
     $action->actionClass->set('RuleActionPercentageDiscount');
     $action->save();
     $randomCategory = Category::getNewInstance(Category::getRootNode());
     $randomCategory->save();
     DiscountConditionRecord::getNewInstance($actionCondition, $randomCategory)->save();
     $this->order->addProduct($product, 1, true);
     $this->order->save();
     Category::recalculateProductsCount();
     $product->reload();
     $this->assertFalse(RuleCondition::create($actionCondition)->isProductMatching($product));
     $customCategory = Category::getNewInstance(Category::getRootNode());
     $customCategory->save();
     ProductCategory::getNewInstance($product, $customCategory)->save();
     DiscountConditionRecord::getNewInstance($actionCondition, $customCategory)->save();
     Category::recalculateProductsCount();
     $product->reload();
     $actionCondition->loadAll();
     $this->assertTrue(RuleCondition::create($actionCondition)->isProductMatching($product));
     $this->assertEquals(count($this->order->getDiscountActions(true)), 1);
     $this->assertEquals($this->products[1]->getPrice($this->usd) * 0.9, $this->order->getTotal(true));
     ActiveRecordModel::clearPool();
     $order = CustomerOrder::getInstanceByID($this->order->getID());
     $order->loadAll();
     $this->assertEquals($this->products[1]->getPrice($this->usd) * 0.9, $this->order->getTotal(true));
 }
开发者ID:saiber,项目名称:livecart,代码行数:40,代码来源:OrderTest.php

示例10: move

 /**
  * Reorder category node
  *
  * @role !category.sort
  */
 public function move()
 {
     $targetNode = Category::getInstanceByID((int) $this->request->get("id"));
     $parentNode = Category::getInstanceByID((int) $this->request->get("parent"));
     $next = $this->request->get("next") ? Category::getInstanceByID((int) $this->request->get("next")) : null;
     try {
         $targetNode->moveTo($parentNode, $next);
         Category::reindex();
         Category::recalculateProductsCount();
         return new JSONResponse(false, 'success', $this->translate('_categories_tree_was_reordered'));
     } catch (Exception $e) {
         return new JSONResponse(false, 'failure', $this->translate('_unable_to_reorder_categories_tree'));
     }
 }
开发者ID:saiber,项目名称:livecart,代码行数:19,代码来源:CategoryController.php


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