コード例 #1
0
/**
 * Generates manufacturer page URL
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 *
 * @package application.helper.smarty
 * @author Integry Systems
 */
function smarty_function_manufacturerUrl($params, LiveCartSmarty $smarty)
{
    $manufacturer = $params['data'];
    $params['data'] =& Category::getRootNode()->toArray();
    $params['addFilter'] = new ManufacturerFilter($manufacturer['ID'], $manufacturer['name']);
    return createCategoryUrl($params, $smarty->getApplication());
}
コード例 #2
0
 private function getFilterUrlTemplate()
 {
     include_once ClassLoader::getRealPath('application.helper.smarty') . '/function.categoryUrl.php';
     $params = array('filters' => array(new ManufacturerFilter(999, '___')), 'data' => Category::getRootNode()->toArray());
     $templateUrl = createCategoryUrl($params, $this->application);
     return strtr($templateUrl, array(999 => '#', '___' => '|'));
 }
コード例 #3
0
ファイル: SitemapController.php プロジェクト: saiber/www
 private function getCategoryEntry($row, $params)
 {
     $row['name'] = unserialize($row['name']);
     $row = MultilingualObject::transformArray($row, ActiveRecord::getSchemaInstance('Category'));
     return array('loc' => $this->router->createFullUrl(createCategoryUrl(array('data' => $row, 'params' => $params), $this->application)));
 }
コード例 #4
0
ファイル: function.categoryUrl.php プロジェクト: saiber/www
/**
 * Generates category page URL
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 *
 * @package application.helper.smarty
 * @author Integry Systems
 */
function smarty_function_categoryUrl($params, LiveCartSmarty $smarty)
{
    return createCategoryUrl($params, $smarty->getApplication());
}
コード例 #5
0
ファイル: ProductController.php プロジェクト: saiber/www
 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;
 }
コード例 #6
0
/**
 * Generates category page URL
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 *
 * @package application.helper.smarty
 * @author Integry Systems
 */
function smarty_function_categoryUrl($params, Smarty_Internal_Template $smarty)
{
    return createCategoryUrl($params, $smarty->getApplication());
}
コード例 #7
0
 /**
  *  Create breadcrumb
  */
 private function setUpBreadCrumbAndReturnFilterChainHandle($page)
 {
     // get category path for breadcrumb
     $path = $this->getCategory()->getPathNodeArray();
     include_once ClassLoader::getRealPath('application.helper.smarty') . '/function.categoryUrl.php';
     foreach ($path as $nodeArray) {
         $url = createCategoryUrl(array('data' => $nodeArray), $this->application);
         if (array_key_exists('name_lang', $nodeArray)) {
             $this->addBreadCrumb($nodeArray['name_lang'], $url);
         }
     }
     // add filters to breadcrumb
     if (!isset($nodeArray)) {
         $nodeArray = $this->getCategory()->toArray();
     }
     $params = array('data' => $nodeArray, 'filters' => array());
     foreach ($this->filters as $filter) {
         $filter = $filter->toArray();
         $params['filters'][] = $filter;
         // add current page number to the last item URL
         if (count($params['filters']) == count($this->filters)) {
             $params['page'] = $page;
         }
         $url = createCategoryUrl($params, $this->application);
         $this->addBreadCrumb($filter['name_lang'], $url);
     }
     // set return path
     if (isset($url)) {
         $this->router->setReturnPath($this->router->getRouteFromUrl($url));
     }
     // get filter chain handle
     $filterChainHandle = array();
     if (!empty($params['filters'])) {
         foreach ($params['filters'] as $filter) {
             $filterChainHandle[] = filterHandle($filter);
         }
     }
     return implode(',', $filterChainHandle);
 }
コード例 #8
0
ファイル: CatalogController.php プロジェクト: saiber/livecart
 protected function addFiltersToBreadCrumb($category, $page = 1)
 {
     include_once ClassLoader::getRealPath('application.helper.smarty') . '/function.categoryUrl.php';
     // add filters to breadcrumb
     if (!isset($category)) {
         $category = $this->getCategory()->toArray();
     }
     $params = array('data' => $category, 'filters' => array());
     foreach ($this->filters as $filter) {
         $filter = $filter->toArray();
         $params['filters'][] = $filter;
         // add current page number to the last item URL
         if (count($params['filters']) == count($this->filters)) {
             $params['page'] = $page;
         }
         $url = createCategoryUrl($params, $this->application);
         if ($this->config->get('BREADCRUMB_FILTERS')) {
             $this->addBreadCrumb($filter['name_lang'], $url);
         }
     }
     // set return path
     if (isset($url)) {
         $this->router->setReturnPath($this->router->getRouteFromUrl($url));
     }
     return $params;
 }