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


PHP Feature::getFeaturesForComparison方法代码示例

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


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

示例1: process

 public function process()
 {
     parent::process();
     $hasProduct = false;
     $product_list = Tools::getValue('compare_product_list');
     $postProducts = isset($product_list) ? rtrim($product_list, '|') : '';
     if (!Configuration::get('PS_COMPARATOR_MAX_ITEM')) {
         return Tools::redirect('404.php');
     }
     if ($postProducts) {
         $ids = array_unique(explode('|', $postProducts));
         if (sizeof($ids) > 0) {
             if (sizeof($ids) > Configuration::get('PS_COMPARATOR_MAX_ITEM')) {
                 $ids = array_slice($ids, 0, Configuration::get('PS_COMPARATOR_MAX_ITEM'));
             }
             $listProducts = array();
             $listFeatures = array();
             foreach ($ids as $id) {
                 $curProduct = new Product((int) $id, true, (int) self::$cookie->id_lang);
                 if (!Validate::isLoadedObject($curProduct)) {
                     continue;
                 }
                 if (!$curProduct->active) {
                     unset($ids[$k]);
                     continue;
                 }
                 foreach ($curProduct->getFrontFeatures(self::$cookie->id_lang) as $feature) {
                     $listFeatures[$curProduct->id][$feature['id_feature']] = $feature['value'];
                 }
                 $cover = Product::getCover((int) $id);
                 $curProduct->id_image = Tools::htmlentitiesUTF8(Product::defineProductImage(array('id_image' => $cover['id_image'], 'id_product' => $id), self::$cookie->id_lang));
                 $curProduct->allow_oosp = Product::isAvailableWhenOutOfStock($curProduct->out_of_stock);
                 $listProducts[] = $curProduct;
             }
             if (sizeof($listProducts) > 0) {
                 $width = 80 / sizeof($listProducts);
                 $hasProduct = true;
                 $ordered_features = Feature::getFeaturesForComparison($ids, self::$cookie->id_lang);
                 self::$smarty->assign(array('ordered_features' => $ordered_features, 'product_features' => $listFeatures, 'products' => $listProducts, 'link' => new Link(), 'width' => $width, 'homeSize' => Image::getSize('home')));
                 self::$smarty->assign('HOOK_EXTRA_PRODUCT_COMPARISON', Module::hookExec('extraProductComparison', array('list_ids_product' => $ids)));
             }
         }
     }
     self::$smarty->assign('hasProduct', $hasProduct);
 }
开发者ID:priyankajsr19,项目名称:indusdiva2,代码行数:45,代码来源:CompareController.php

示例2: initContent

 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     //Clean compare product table
     CompareProduct::cleanCompareProducts('week');
     $hasProduct = false;
     if (!Configuration::get('PS_COMPARATOR_MAX_ITEM')) {
         return Tools::redirect('index.php?controller=404');
     }
     if (($product_list = Tools::getValue('compare_product_list')) && ($postProducts = isset($product_list) ? rtrim($product_list, '|') : '')) {
         $ids = array_unique(explode('|', $postProducts));
     } else {
         if (isset($this->context->cookie->id_compare)) {
             $ids = CompareProduct::getCompareProducts($this->context->cookie->id_compare);
         } else {
             $ids = null;
         }
     }
     if ($ids) {
         if (count($ids) > 0) {
             if (count($ids) > Configuration::get('PS_COMPARATOR_MAX_ITEM')) {
                 $ids = array_slice($ids, 0, Configuration::get('PS_COMPARATOR_MAX_ITEM'));
             }
             $listProducts = array();
             $listFeatures = array();
             foreach ($ids as $k => &$id) {
                 $curProduct = new Product((int) $id, true, $this->context->language->id);
                 if (!Validate::isLoadedObject($curProduct) || !$curProduct->active || !$curProduct->isAssociatedToShop()) {
                     if (isset($this->context->cookie->id_compare)) {
                         CompareProduct::removeCompareProduct($this->context->cookie->id_compare, $id);
                     }
                     unset($ids[$k]);
                     continue;
                 }
                 foreach ($curProduct->getFrontFeatures($this->context->language->id) as $feature) {
                     $listFeatures[$curProduct->id][$feature['id_feature']] = $feature['value'];
                 }
                 $cover = Product::getCover((int) $id);
                 $curProduct->id_image = Tools::htmlentitiesUTF8(Product::defineProductImage(array('id_image' => $cover['id_image'], 'id_product' => $id), $this->context->language->id));
                 $curProduct->allow_oosp = Product::isAvailableWhenOutOfStock($curProduct->out_of_stock);
                 $listProducts[] = $curProduct;
             }
             if (count($listProducts) > 0) {
                 $width = 80 / count($listProducts);
                 $hasProduct = true;
                 $ordered_features = Feature::getFeaturesForComparison($ids, $this->context->language->id);
                 $this->context->smarty->assign(array('ordered_features' => $ordered_features, 'product_features' => $listFeatures, 'products' => $listProducts, 'width' => $width, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
                 $this->context->smarty->assign('HOOK_EXTRA_PRODUCT_COMPARISON', Hook::exec('displayProductComparison', array('list_ids_product' => $ids)));
             } else {
                 if (isset($this->context->cookie->id_compare)) {
                     $object = new CompareProduct((int) $this->context->cookie->id_compare);
                     if (Validate::isLoadedObject($object)) {
                         $object->delete();
                     }
                 }
             }
         }
     }
     $this->context->smarty->assign('hasProduct', $hasProduct);
     $this->setTemplate(_PS_THEME_DIR_ . 'products-comparison.tpl');
 }
开发者ID:FAVHYAN,项目名称:a3workout,代码行数:65,代码来源:CompareController.php


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