Jump to content

Prix TTC dans le bloc "Déja vu"


Recommended Posts

J'utilise le module par defaut de la RC4, soit :

function hookRightColumn($params)
   {
       global $link, $smarty;
       $id_product = intval(Tools::getValue('id_product'));
       if ($id_product)
           $product = new Product($id_product);
       $productsViewed = (isset($params['cookie']->viewed) AND !empty($params['cookie']->viewed)) ? array_slice(explode(',', $params['cookie']->viewed), 0, Configuration::get('PRODUCTS_VIEWED_NBR')) : array();
       if (sizeof($productsViewed))
       {
           $productsViewedObj = array();
           foreach ($productsViewed AS $productViewed)
           {
               $obj = new Product(intval($productViewed), false, intval($params['cookie']->id_lang));
               if (!Validate::isLoadedObject($obj))
                   continue;
               else
               {
                   $images = $obj->getImages(intval($params['cookie']->id_lang));
                   foreach ($images AS $k => $image)
                   {
                       if ($image['cover'])
                       {
                           $obj->cover = $obj->id.'-'.$image['id_image'];
                           $obj->legend = $image['legend'];
                           break;
                       }
                   }
                   if (!isset($obj->cover))
                   {
                       $obj->cover = Language::getIsoById($params['cookie']->id_lang).'-default';
                       $obj->legend = '';
                   }
                   $productsViewedObj[] = $obj;
               }
           }
           if (isset($product) AND $product AND !in_array($product->id, $productsViewed))
               array_unshift($productsViewed, $product->id);
           $viewed = '';
           foreach ($productsViewed AS $id_product_viewed)
               $viewed .= intval($id_product_viewed).',';
           $params['cookie']->viewed = rtrim($viewed, ',');

           if (!sizeof($productsViewedObj))
               return ;
           print_r($productsViewedObj);
           $smarty->assign('productsViewedObj', $productsViewedObj);
           return $this->display(__FILE__, 'blockviewed.tpl');
       }
       elseif (isset($product) AND Validate::isLoadedObject($product))
           $params['cookie']->viewed = intval($product->id);
       return ;
   }



Lorsque je fait un print_r de $productsViewedObj je n'ai a aucun moment le pric TTC.

Link to comment
Share on other sites

Je n'ai pas trouvé la classe our_price_display, mais j'ai trouvé ma solution en regardant le module bestsellers

function hookRightColumn($params)
   {
       global $link, $smarty;
       $id_product = intval(Tools::getValue('id_product'));
       if ($id_product)
           $product = new Product($id_product);
       $productsViewed = (isset($params['cookie']->viewed) AND !empty($params['cookie']->viewed)) ? array_slice(explode(',', $params['cookie']->viewed), 0, Configuration::get('PRODUCTS_VIEWED_NBR')) : array();
       if (sizeof($productsViewed))
       {
           $productsViewedObj = array();
           foreach ($productsViewed AS $productViewed)
           {
               $obj = new Product(intval($productViewed), false, intval($params['cookie']->id_lang));
               if (!Validate::isLoadedObject($obj))
                   continue;
               else
               {
                   $images = $obj->getImages(intval($params['cookie']->id_lang));
                   foreach ($images AS $k => $image)
                   {
                       if ($image['cover'])
                       {
                           $obj->cover = $obj->id.'-'.$image['id_image'];
                           $obj->legend = $image['legend'];
                           break;
                       }
                   }
                   if (!isset($obj->cover))
                   {
                       $obj->cover = Language::getIsoById($params['cookie']->id_lang).'-default';
                       $obj->legend = '';
                   }
                   $obj->price = $obj->getPriceStatic(intval($productViewed));
                   $productsViewedObj[] = $obj;
               }
           }
           if (isset($product) AND $product AND !in_array($product->id, $productsViewed))
               array_unshift($productsViewed, $product->id);
           $viewed = '';
           foreach ($productsViewed AS $id_product_viewed)
               $viewed .= intval($id_product_viewed).',';
           $params['cookie']->viewed = rtrim($viewed, ',');

           if (!sizeof($productsViewedObj))
               return ;
           $smarty->assign('productsViewedObj', $productsViewedObj);
           return $this->display(__FILE__, 'blockviewed.tpl');
       }
       elseif (isset($product) AND Validate::isLoadedObject($product))
           $params['cookie']->viewed = intval($product->id);
       return ;
   }



La solution est dans le rajout de la ligne :

$obj->price = $obj->getPriceStatic(intval($productViewed));



Merci encore, et vive Presta.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...