Beispiel #1
0
 public function index()
 {
     $this->loadLanguageFile('Category');
     $product = Product::getInstanceByID($this->request->get('id'), Product::LOAD_DATA, array('ProductImage', 'Manufacturer', 'Category'));
     $this->product = $product;
     if (!$product->isEnabled->get() || $product->parent->get()) {
         throw new ARNotFoundException('Product', $product->getID());
     }
     $product->loadPricing();
     $this->category = $product->getCategory();
     $this->categoryID = $product->getCategory()->getID();
     // get category path for breadcrumb
     $path = $product->category->get()->getPathNodeArray();
     include_once ClassLoader::getRealPath('application.helper.smarty') . '/function.categoryUrl.php';
     include_once ClassLoader::getRealPath('application.helper.smarty') . '/function.productUrl.php';
     foreach ($path as $nodeArray) {
         $url = createCategoryUrl(array('data' => $nodeArray), $this->application);
         if ($nodeArray['isEnabled']) {
             $this->addBreadCrumb($nodeArray['name_lang'], $url);
         }
     }
     // add filters to breadcrumb
     CategoryController::getAppliedFilters();
     // for root category products
     if (!isset($nodeArray)) {
         $nodeArray = array();
     }
     $params = array('data' => $nodeArray, 'filters' => array());
     foreach ($this->filters as $filter) {
         $f = $filter->toArray();
         $params['filters'][] = $f;
         $url = createCategoryUrl($params, $this->application);
         $this->addBreadCrumb($f['name_lang'], $url);
     }
     $productArray = $product->toArray();
     $handle = empty($productArray['URL']) ? $productArray['name_lang'] : $productArray['URL'];
     $this->redirect301($this->request->get('producthandle'), createHandleString($handle));
     //ProductSpecification::loadSpecificationForProductArray($productArray);
     // filter empty attributes
     foreach ($productArray['attributes'] as $key => $attr) {
         if (empty($attr['value']) && empty($attr['values']) && empty($attr['value_lang'])) {
             unset($productArray['attributes'][$key]);
         }
     }
     // attribute summary
     $productArray['listAttributes'] = array();
     foreach ($productArray['attributes'] as $key => $attr) {
         if ($attr['SpecField']['isDisplayedInList']) {
             $productArray['listAttributes'][] = $attr;
         }
         if (!$attr['SpecField']['isDisplayed']) {
             unset($productArray['attributes'][$key]);
         }
     }
     // add product title to breacrumb
     $this->addBreadCrumb($productArray['name_lang'], createProductUrl(array('product' => $productArray), $this->application));
     // manufacturer filter
     if ($product->manufacturer->get()) {
         $manFilter = new ManufacturerFilter($product->manufacturer->get()->getID(), $product->manufacturer->get()->name->get());
     }
     // get category page route
     end($this->breadCrumb);
     $last = prev($this->breadCrumb);
     $catRoute = $this->router->getRouteFromUrl($last['url']);
     $response = new ActionResponse();
     $response->set('product', $productArray);
     $response->set('category', $productArray['Category']);
     $response->set('quantity', $this->getQuantities($product));
     $response->set('currency', $this->request->get('currency', $this->application->getDefaultCurrencyCode()));
     $response->set('catRoute', $catRoute);
     // ratings
     if ($this->config->get('ENABLE_RATINGS')) {
         if ($product->ratingCount->get() > 0) {
             // rating summaries
             ClassLoader::import('application.model.product.ProductRatingSummary');
             $response->set('rating', ProductRatingSummary::getProductRatingsArray($product));
         }
         ClassLoader::import('application.model.category.ProductRatingType');
         $ratingTypes = ProductRatingType::getProductRatingTypeArray($product);
         $response->set('ratingTypes', $ratingTypes);
         $response->set('ratingForm', $this->buildRatingForm($ratingTypes, $product));
         $response->set('isRated', $this->isRated($product));
         $response->set('isLoginRequiredToRate', $this->isLoginRequiredToRate());
         $response->set('isPurchaseRequiredToRate', $this->isPurchaseRequiredToRate($product));
     }
     // add to cart form
     $response->set('cartForm', $this->buildAddToCartForm($this->getOptions(), $this->getVariations()));
     // related products
     $related = $this->getRelatedProducts($product);
     // items purchased together
     $together = $product->getProductsPurchasedTogether($this->config->get('NUM_PURCHASED_TOGETHER'), true);
     $spec = array();
     foreach ($related as $key => $group) {
         foreach ($related[$key] as $i => &$prod) {
             $spec[] =& $related[$key][$i];
         }
     }
     foreach ($together as &$prod) {
         $spec[] =& $prod;
     }
     ProductSpecification::loadSpecificationForRecordSetArray($spec);
     $response->set('related', $related);
     $response->set('together', $together);
     if (isset($manFilter)) {
         $response->set('manufacturerFilter', $manFilter);
     }
     $response->set('variations', $this->getVariations());
     // reviews
     if ($this->config->get('ENABLE_REVIEWS') && $product->reviewCount->get() && ($numReviews = $this->config->get('NUM_REVIEWS_IN_PRODUCT_PAGE'))) {
         $f = new ARSelectFilter(new EqualsCond(new ARFieldHandle('ProductReview', 'isEnabled'), true));
         $f->setLimit($numReviews);
         $reviews = $product->getRelatedRecordSetArray('ProductReview', $f);
         $this->pullRatingDetailsForReviewArray($reviews);
         $response->set('reviews', $reviews);
     }
     // bundled products
     if ($product->isBundle()) {
         $bundleData = ProductBundle::getBundledProductArray($product);
         $bundledProducts = array();
         foreach ($bundleData as &$bundled) {
             $bundledProducts[] =& $bundled['RelatedProduct'];
         }
         ProductPrice::loadPricesForRecordSetArray($bundledProducts);
         $response->set('bundleData', $bundleData);
         $currency = Currency::getInstanceByID($this->getRequestCurrency());
         $total = ProductBundle::getTotalBundlePrice($product, $currency);
         $response->set('bundleTotal', $currency->getFormattedPrice($total));
         $saving = $total - $product->getPrice($currency);
         $response->set('bundleSavingTotal', $currency->getFormattedPrice($saving));
         $response->set('bundleSavingPercent', $total ? round($saving / $total * 100) : 0);
     }
     // contact form
     if ($this->config->get('PRODUCT_INQUIRY_FORM')) {
         $response->set('contactForm', $this->buildContactForm());
     }
     // display theme
     if ($theme = CategoryPresentation::getThemeByProduct($product)) {
         if ($theme->getTheme()) {
             $this->application->setTheme($theme->getTheme());
         }
         $response->set('presentation', $theme->toFlatArray());
     }
     // product images
     $images = $product->getImageArray();
     if ($theme && $theme->isVariationImages->get()) {
         if ($variations = $this->getVariations()) {
             foreach ($variations['products'] as $prod) {
                 if (!empty($prod['DefaultImage']['ID'])) {
                     $images[] = $prod['DefaultImage'];
                 }
             }
         }
     }
     $response->set('images', $images);
     // discounted pricing
     $response->set('quantityPricing', $product->getPricingHandler()->getDiscountPrices($this->user, $this->getRequestCurrency()));
     $response->set('files', $this->getPublicFiles());
     // additional categories
     $f = new ARSelectFilter();
     $f->setOrder(new ARFieldHandle('Category', 'lft'));
     $f->mergeCondition(new EqualsCond(new ARFieldHandle('Category', 'isEnabled'), true));
     $pathC = new OrChainCondition();
     $pathF = new ARSelectFilter($pathC);
     $categories = array();
     foreach ($product->getRelatedRecordSetArray('ProductCategory', $f, array('Category')) as $cat) {
         $categories[] = array($cat['Category']);
         $cond = new OperatorCond(new ARFieldHandle('Category', 'lft'), $cat['Category']['lft'], "<");
         $cond->addAND(new OperatorCond(new ARFieldHandle('Category', 'rgt'), $cat['Category']['rgt'], ">"));
         $pathC->addAnd($cond);
     }
     if ($categories) {
         $pathF->setOrder(new ARFieldHandle('Category', 'lft'), 'DESC');
         $pathF->mergeCondition(new EqualsCond(new ARFieldHandle('Category', 'isEnabled'), true));
         foreach (ActiveRecordModel::getRecordSetArray('Category', $pathF, array('Category')) as $parent) {
             if (!$parent['isEnabled']) {
                 continue;
             }
             foreach ($categories as &$cat) {
                 if ($cat[0]['lft'] > $parent['lft'] && $cat[0]['rgt'] < $parent['rgt'] && $parent['ID'] > Category::ROOT_ID) {
                     $cat[] = $parent;
                 }
             }
         }
         foreach ($categories as &$cat) {
             $cat = array_reverse($cat);
         }
         $response->set('additionalCategories', $categories);
     }
     $response->set('enlargeProductThumbnailOnMouseOver', $this->config->get('_ENLARGE_PRODUCT_THUMBNAILS_ON') == 'P_THUMB_ENLARGE_MOUSEOVER');
     return $response;
 }
Beispiel #2
0
 private function save(Product $product)
 {
     ClassLoader::import('application.model.presentation.CategoryPresentation');
     $validator = $this->buildValidator($product);
     if ($validator->isValid()) {
         $product->loadRequestData($this->request);
         foreach (array('ShippingClass' => 'shippingClassID', 'TaxClass' => 'taxClassID') as $class => $field) {
             $value = $this->request->get($field, null);
             $instance = $value ? ActiveRecordModel::getInstanceByID($class, $value) : null;
             $product->setFieldValue($field, $instance);
         }
         $product->save();
         // presentation
         $instance = CategoryPresentation::getInstance($product);
         $instance->loadRequestData($this->request);
         $instance->save();
         // save pricing
         $product->loadSpecification();
         $product->loadPricing();
         if ($quantities = $this->request->get('quantityPricing')) {
             foreach ($product->getRelatedRecordSet('ProductPrice', new ARSelectFilter()) as $price) {
                 $id = $price->currency->get()->getID();
                 $prices = array();
                 if (!empty($quantities[$id])) {
                     $values = json_decode($quantities[$id], true);
                     $prices = array();
                     // no group selected - set all customers
                     if ('' == $values['group'][0]) {
                         $values['group'][0] = 0;
                     }
                     $quantCount = count($values['quant']);
                     foreach ($values['group'] as $groupIndex => $group) {
                         foreach ($values['quant'] as $quantIndex => $quant) {
                             $pr = $values['price'][$groupIndex * $quantCount + $quantIndex];
                             if (strlen($pr) != 0) {
                                 $prices[$quant][$group] = (double) $pr;
                             }
                         }
                     }
                 }
                 ksort($prices);
                 $price->serializedRules->set(serialize($prices));
                 $price->save();
             }
         }
         // $product->loadRequestData($this->request);
         // $product->save();
         if ($this->isQuickEdit == false) {
             BackendToolbarItem::registerLastViewedProduct($product);
         }
         $response = $this->productForm($product);
         $response->setHeader('Cache-Control', 'no-cache, must-revalidate');
         $response->setHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT');
         $response->setHeader('Content-type', 'text/javascript');
         return $response;
     } else {
         // reset validator data (as we won't need to restore the form)
         $validator->restore();
         return new JSONResponse(array('errors' => $validator->getErrorList(), 'failure', $this->translate('_could_not_save_product_information')));
     }
 }
 /**
  * Updates a category record
  *
  * @role !category.update
  *
  * @return ActionRedirectResponse
  */
 public function update()
 {
     ClassLoader::import('application.model.presentation.CategoryPresentation');
     $categoryNode = Category::getInstanceByID($this->request->get("id"), Category::LOAD_DATA);
     $validator = $this->buildValidator($categoryNode);
     if ($validator->isValid()) {
         $categoryNode->loadRequestData($this->request);
         $categoryNode->save();
         // presentation
         $instance = CategoryPresentation::getInstance($categoryNode);
         $instance->loadRequestData($this->request);
         $instance->save();
         return new JSONResponse($categoryNode->toFlatArray(), 'success', $this->translate('_category_succsessfully_saved'));
     }
 }
 public function index()
 {
     ClassLoader::import('application.model.presentation.CategoryPresentation');
     $this->getAppliedFilters();
     // presentation
     if ($theme = CategoryPresentation::getThemeByCategory($this->getCategory())) {
         if ($theme->getTheme()) {
             $this->application->setTheme($theme->getTheme());
         }
         if ($layout = $theme->listStyle->get()) {
             $this->request->set('layout', strtolower($layout));
             $this->config->set('LIST_LAYOUT', $layout);
             $this->config->set('ALLOW_SWITCH_LAYOUT', false);
         }
     }
     // pagination
     $currentPage = $this->request->get('page', 1);
     $listLayout = $this->getListLayout();
     $perPage = $this->getProductLimitCount($listLayout);
     $offsetStart = ($currentPage - 1) * $perPage + 1;
     $offsetEnd = $currentPage * $perPage;
     $selectFilter = new ARSelectFilter();
     $selectFilter->setLimit($perPage, $offsetStart - 1);
     $this->application->processInstancePlugins('productFilter', $selectFilter);
     // create new search filter
     $query = $this->request->get('q');
     if ($query) {
         $searchFilter = new SearchFilter($query);
         $this->filters[] = $searchFilter;
         // search by category names
         $f = new ARSelectFilter();
         foreach (array($this->locale->getLocaleCode(), $this->application->getDefaultLanguageCode()) as $handle) {
             $langHandle = MultiLingualObject::getLangSearchHandle(new ARFieldHandle('Category', 'name'), $handle);
             $f->mergeCondition(new LikeCond($langHandle, '%' . $query . '%'));
         }
         $foundCategories = ActiveRecordModel::getRecordSet('Category', $f, Category::LOAD_REFERENCES);
         foreach ($foundCategories as $category) {
             $category->getPathNodeSet();
         }
         $cleanedQuery = $searchFilter->getCleanedQuery($query);
         $this->logSearchQuery($cleanedQuery);
     }
     // root category?
     if ($this->getCategory()->isRoot() && !$this->filters && !$this instanceof IndexController && !$this->request->get('includeSub') && $currentPage > 1) {
         return new ActionRedirectResponse('index', 'index');
     }
     // sorting
     $sort = array();
     $opts = $this->config->get('ALLOWED_SORT_ORDER');
     if ($opts) {
         foreach ($opts as $opt => $status) {
             $sort[strtolower($opt)] = $this->translate($opt);
         }
     }
     foreach ($this->getCategory()->getSpecificationFieldArray() as $field) {
         if ($field['isSortable']) {
             $sortName = $field['dataType'] == SpecField::DATATYPE_NUMBERS ? '_sort_num' : '_sort_text';
             $sort[$field['ID'] . '-' . $field['handle'] . '_asc'] = $this->maketext($sortName . '_asc', $field['name_lang']);
             $sort[$field['ID'] . '-' . $field['handle'] . '_desc'] = $this->maketext($sortName . '_desc', $field['name_lang']);
         }
     }
     $order = $this->request->get('sort');
     $defOrder = strtolower($this->config->get('SORT_ORDER'));
     if (!$order) {
         $order = $defOrder;
     }
     $this->applySortOrder($selectFilter, $order);
     // setup ProductFilter
     $productFilter = new ProductFilter($this->getCategory(), $selectFilter);
     if ($this->config->get('INCLUDE_SUBCATEGORY_PRODUCTS')) {
         $productFilter->includeSubcategories();
     }
     $this->productFilter = $productFilter;
     foreach ($this->filters as $filter) {
         $productFilter->applyFilter($filter);
         if ($filter instanceof SearchFilter) {
             $productFilter->includeSubcategories();
             $searchQuery = $filter->getKeywords();
         }
     }
     if ($this->getCategory()->isRoot() && $this->filters || $this->filters || $this->request->get('includeSub')) {
         $productFilter->includeSubcategories();
     }
     $products = $this->getProductsArray($productFilter);
     $this->hasProducts = count($products) > 0;
     // pagination
     $count = new ProductCount($this->productFilter, $this->application);
     $totalCount = $count->getCategoryProductCount($productFilter);
     $offsetEnd = min($totalCount, $offsetEnd);
     $this->totalCount = $totalCount;
     // narrow by subcategories
     $subCategories = $this->getCategory()->getSubCategoryArray(Category::LOAD_REFERENCES);
     $categoryNarrow = array();
     if ((!empty($searchQuery) || $this->getCategory()->isRoot() || $this->filters) && $products) {
         $categoryNarrow = $this->getSubCategoriesBySearchQuery($productFilter->getSelectFilter(), $subCategories);
     }
     $categoryArray = $this->getCategory()->toArray();
     if (!$this->getCategory()->isRoot()) {
         $this->redirect301($this->request->get('cathandle'), createHandleString($categoryArray['name_lang']));
     }
     // if all the results come from one category, redirect to this category
     if (count($categoryNarrow) == 1 && count($this->filters) == 1 && empty($foundCategories)) {
         $canNarrow = true;
         foreach ($products as $product) {
             if ($product['Category']['ID'] == $this->getCategoryId()) {
                 $canNarrow = false;
             }
         }
         if ($canNarrow) {
             while (count($categoryNarrow) == 1) {
                 if ($categoryNarrow[0]['searchCount'] != $totalCount) {
                     break;
                 }
                 $this->category = Category::getInstanceByID($categoryNarrow[0]['ID'], Category::LOAD_DATA);
                 $subCategories = $this->getCategory()->getSubCategoryArray(Category::LOAD_REFERENCES);
                 if ($subCategories) {
                     $subCategories[] = $categoryArray;
                 }
                 $categoryNarrow = $this->getSubCategoriesBySearchQuery($selectFilter, $subCategories);
             }
             include_once ClassLoader::getRealPath('application.helper.smarty') . '/function.categoryUrl.php';
             if (!$this->getCategory()->isRoot()) {
                 return new RedirectResponse(createCategoryUrl(array('data' => $this->getCategory()->toArray(), 'filters' => $this->filters), $this->application));
             }
         }
     }
     // get subcategory-subcategories
     if ($subCategories && $this->config->get('CAT_MENU_SUBS')) {
         $this->getSubSubCategories($subCategories);
     }
     // get subcategory featured products
     $subCatFeatured = array();
     if ($subCategories && !$products || $this instanceof IndexController) {
         $subCatFeatured = $this->getSubCatFeaturedProducts();
     }
     // if there were no products found, include subcategories in filter counts... except home page
     if (!$products || $this->getCategory()->isRoot()) {
         $selectFilter->removeCondition(new EqualsCond(new ARFieldHandle('Product', 'categoryID'), $this->getCategory()->getID()));
         $this->productFilter->includeSubcategories();
     }
     // search redirects
     // no products found, but found one category name - redirect to this category
     if (isset($foundCategories) && 1 == $foundCategories->size() && !$products) {
         include_once ClassLoader::getRealPath('application.helper.smarty') . '/function.categoryUrl.php';
         return new RedirectResponse(createCategoryUrl(array('data' => $foundCategories->get(0)->toArray()), $this->application));
     }
     $filterArray = array();
     foreach ($this->filters as $filter) {
         $filterArray[] = $filter->toArray();
     }
     if ($this->config->get('DISPLAY_CATEGORY_FEATURED')) {
         $this->getFeaturedMainCategoryProducts($subCategories);
         $this->getFeaturedMainCategoryProducts($categoryNarrow);
     }
     $response = new ActionResponse();
     $response->set('id', $this->getCategoryId());
     $response->set('products', $products);
     $response->set('count', $totalCount);
     $response->set('offsetStart', $offsetStart);
     $response->set('offsetEnd', $offsetEnd);
     $response->set('perPage', $perPage);
     $response->set('currentPage', $currentPage);
     $response->set('category', $categoryArray);
     $response->set('subCategories', $subCategories);
     $response->set('currency', $this->getRequestCurrency());
     $response->set('sortOptions', $sort);
     $response->set('sortForm', $this->buildSortForm($order));
     $response->set('sortField', $order);
     $response->set('categoryNarrow', $categoryNarrow);
     $response->set('subCatFeatured', $subCatFeatured);
     //$response->set('allFilters', $filters);
     //$response->set('showAll', $showAll);
     $response->set('appliedFilters', $filterArray);
     $response->set('layout', $listLayout);
     $response->set('listAttributes', $this->getListAttributes());
     $filterChainHandle = $this->setUpBreadCrumbAndReturnFilterChainHandle($currentPage);
     $response->set('url', $this->getCategoryPageUrl(array('page' => '_000_', 'filters' => $filterChainHandle)));
     $response->set('layoutUrl', $this->getCategoryPageUrl(array('filters' => $filterChainHandle, 'query' => array('layout' => ''))));
     $response->set('filterChainHandle', $filterChainHandle);
     if (isset($searchQuery)) {
         $response->set('searchQuery', $searchQuery);
     }
     if (isset($foundCategories)) {
         $response->set('foundCategories', $foundCategories->toArray());
     }
     // look for manufacturer filter
     foreach ($this->filters as $filter) {
         if ($filter instanceof ManufacturerFilter) {
             $response->set('manufacturerFilter', $filter->toArray());
         }
     }
     if (1 == $currentPage && $query) {
         $searchCon = new SearchController($this->application);
         $response->set('modelSearch', $searchCon->searchAll($cleanedQuery));
     }
     return $response;
 }
 protected function processRecord(Product $product)
 {
     $act = $this->getAction();
     $field = $this->getField();
     if ('manufacturer' == $act) {
         $product->manufacturer->set($this->params['manufacturer']);
     } else {
         if ('price' == $act) {
             $product->setPrice($this->params['baseCurrency'], $this->params['price']);
         } else {
             if (in_array($act, array('inc_price', 'multi_price', 'div_price'))) {
                 $actions = array('inc_price' => 'increasePriceByPercent', 'multi_price' => 'multiplyPrice', 'div_price' => 'dividePrice');
                 $action = $actions[$act];
                 $pricing = $product->getPricingHandler();
                 foreach ($this->params['currencies'] as $currency) {
                     if ($pricing->isPriceSet($currency)) {
                         $p = $pricing->getPrice($currency);
                         $p->{$action}($this->params['inc_price_value'], $this->params['inc_quant_price']);
                         $p->save();
                     }
                 }
             } else {
                 if ('inc_stock' == $act) {
                     $product->stockCount->set($product->stockCount->get() + $this->request->get($act));
                 } else {
                     if ('addRelated' == $act) {
                         $product->addRelatedProduct($this->params['relatedProduct']);
                     } else {
                         if ('copy' == $act) {
                             $cloned = clone $product;
                             $cloned->category->set($this->params['category']);
                             $cloned->save();
                         } else {
                             if ('addCat' == $act) {
                                 // check if the product is not assigned to this category already
                                 $relation = ActiveRecordModel::getInstanceByIdIfExists('ProductCategory', array('productID' => $product->getID(), 'categoryID' => $this->params['category']->getID()));
                                 if (!$relation->isExistingRecord() && $product->category->get() !== $category) {
                                     $relation->save();
                                 }
                             } else {
                                 if ('theme' == $act) {
                                     $instance = CategoryPresentation::getInstance($product);
                                     $instance->theme->set($this->params['theme']);
                                     $instance->save();
                                 } else {
                                     if ('shippingClass' == $act) {
                                         $product->shippingClass->set(ActiveRecordModel::getInstanceByIDIfExists('ShippingClass', $this->params['shippingClass'], false));
                                     } else {
                                         if ('taxClass' == $act) {
                                             $product->taxClass->set(ActiveRecordModel::getInstanceByIDIfExists('TaxClass', $this->params['taxClass'], false));
                                         } else {
                                             if (substr($act, 0, 13) == 'set_specField') {
                                                 $this->params['request']->remove('manufacturer');
                                                 $product->loadRequestData($this->params['request']);
                                             } else {
                                                 if (substr($act, 0, 16) == 'remove_specField') {
                                                     $this->params['request']->remove('manufacturer');
                                                     if ($this->params['field']->isMultiValue->get()) {
                                                         // remove only selected multi-select options
                                                         $product->loadRequestData($this->params['request']);
                                                     } else {
                                                         $product->removeAttribute($this->params['field']);
                                                     }
                                                 } else {
                                                     parent::processRecord($product);
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 protected function processRecord(Product $product)
 {
     $act = $this->getAction();
     $field = $this->getField();
     if ('manufacturer' == $act) {
         $product->manufacturer->set($this->params['manufacturer']);
     } else {
         if ('price' == $act) {
             $product->setPrice($this->params['baseCurrency'], $this->params['price']);
         } else {
             if ('inc_price' == $act) {
                 $pricing = $product->getPricingHandler();
                 foreach ($this->params['currencies'] as $currency) {
                     if ($pricing->isPriceSet($currency)) {
                         $p = $pricing->getPrice($currency);
                         $p->increasePriceByPercent($this->params['inc_price_value'], $this->params['inc_quant_price']);
                         $p->save();
                     }
                 }
             } else {
                 if ('inc_stock' == $act) {
                     $product->stockCount->set($product->stockCount->get() + $this->request->get($act));
                 } else {
                     if ('addRelated' == $act) {
                         $product->addRelatedProduct($this->params['relatedProduct']);
                     } else {
                         if ('copy' == $act) {
                             $cloned = clone $product;
                             $cloned->category->set($this->params['category']);
                             $cloned->save();
                         } else {
                             if ('addCat' == $act) {
                                 // check if the product is not assigned to this category already
                                 $relation = ActiveRecordModel::getInstanceByIdIfExists('ProductCategory', array('productID' => $product->getID(), 'categoryID' => $this->params['category']->getID()));
                                 if (!$relation->isExistingRecord() && $product->category->get() !== $category) {
                                     $relation->save();
                                 }
                             } else {
                                 if ('theme' == $act) {
                                     $instance = CategoryPresentation::getInstance($product);
                                     $instance->theme->set($this->params['theme']);
                                     $instance->save();
                                 } else {
                                     if ('shippingClass' == $act) {
                                         $product->shippingClass->set(ActiveRecordModel::getInstanceByIDIfExists('ShippingClass', $this->params['shippingClass'], false));
                                     } else {
                                         if ('taxClass' == $act) {
                                             $product->taxClass->set(ActiveRecordModel::getInstanceByIDIfExists('TaxClass', $this->params['taxClass'], false));
                                         } else {
                                             parent::processRecord($product);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }