/** * @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; }
public function loadRequestData(Request $request, $removeMissingPrices = true) { // basic data parent::loadRequestData($request); if (!$this->isExistingRecord()) { $this->save(); } // set manufacturer if ($man = $request->get('Manufacturer')) { $this->manufacturer->set(!empty($man['name']) ? Manufacturer::getInstanceByName($man['name']) : null); } $this->getSpecification()->loadRequestData($request); // set prices $this->loadPricingFromRequest($request, false, $removeMissingPrices); $this->loadPricingFromRequest($request, true, $removeMissingPrices); if ($quantities = $request->get('quantityPrice')) { foreach ($this->getRelatedRecordSet('ProductPrice', new ARSelectFilter()) as $price) { $id = $price->currency->get()->getID(); if (!empty($quantities[$id]['serializedRules'])) { $prices = $quantities[$id]['serializedRules']; ksort($prices); $price->serializedRules->set(serialize($prices)); $price->save(); } } } }
public function loadRequestData(Request $request) { // basic data parent::loadRequestData($request); if (!$this->isExistingRecord()) { $this->save(); } // set manufacturer if ($request->isValueSet('manufacturer')) { $this->manufacturer->set(Manufacturer::getInstanceByName($request->get('manufacturer'))); } $this->getSpecification()->loadRequestData($request); // set prices $this->loadPricingFromRequest($request); $this->loadPricingFromRequest($request, true); }