Пример #1
0
 /**
  * Retourne les éléments du produits formatés pour affichage
  *
  * @param  string $format Le format à utiliser
  * @return array  Les informations formatées
  */
 public function toArray($format = 's')
 {
     $ret = array();
     $ret = parent::toArray($format);
     $oledrion_Currency = oledrion_Currency::getInstance();
     $ttc = $finalPriceTTC = $this->getTTC();
     $finalPriceHT = floatval($this->getVar('product_price'));
     $ret['product_ecotaxe_formated'] = $oledrion_Currency->amountForDisplay($this->getVar('product_ecotaxe'));
     $ret['product_price_formated'] = $oledrion_Currency->amountForDisplay($this->getVar('product_price', 'e'));
     $ret['product_shipping_price_formated'] = $oledrion_Currency->amountForDisplay($this->getVar('product_shipping_price', 'e'));
     $ret['product_discount_price_formated'] = $oledrion_Currency->amountForDisplay($this->getVar('product_discount_price', 'e'));
     $ret['product_price_ttc'] = $oledrion_Currency->amountForDisplay($ttc);
     $ret['product_price_ttc_long'] = $oledrion_Currency->amountForDisplay($ttc, 'l');
     if (intval($this->getVar('product_discount_price')) > 0) {
         //geeker
         $finalPriceTTC = $this->getDiscountTTC();
         $finalPriceHT = floatval($this->getVar('product_discount_price', 'e'));
         $ret['product_discount_price_ttc'] = $oledrion_Currency->amountForDisplay($this->getDiscountTTC());
         $ret['product_discount_price_ttc_long'] = $oledrion_Currency->amountForDisplay($this->getDiscountTTC(), 'l');
     } else {
         $ret['product_discount_price_ttc'] = '';
         $ret['product_discount_price_ttc_long'] = '';
     }
     // Les informations sur les attributs
     $attributesCount = $this->productAttributesCount();
     $ret['product_attributes_count'] = $attributesCount;
     if ($attributesCount > 0) {
         $optionsPrice = $this->getInitialOptionsPrice();
         $ret['product_price_formated'] = $oledrion_Currency->amountForDisplay(floatval($this->getVar('product_price', 'e')) + $optionsPrice);
         $ret['product_discount_price_formated'] = $oledrion_Currency->amountForDisplay(floatval($this->getVar('product_discount_price', 'e')) + $optionsPrice);
         $ret['product_price_ttc'] = $oledrion_Currency->amountForDisplay($ttc + $optionsPrice);
         $ret['product_price_ttc_long'] = $oledrion_Currency->amountForDisplay($ttc + $optionsPrice, 'l');
         if (intval($this->getVar('product_discount_price')) != 0) {
             $finalPriceTTC = $this->getDiscountTTC() + $optionsPrice;
             $finalPriceHT = floatval($this->getVar('product_discount_price', 'e')) + $optionsPrice;
             $ret['product_discount_price_ttc'] = $oledrion_Currency->amountForDisplay(floatval($this->getDiscountTTC()) + $optionsPrice);
             $ret['product_discount_price_ttc_long'] = $oledrion_Currency->amountForDisplay(floatval($this->getDiscountTTC()) + $optionsPrice, 'l');
         }
     }
     $ret['product_final_price_ht_formated_long'] = $oledrion_Currency->amountForDisplay($finalPriceHT, 'l');
     $ret['product_final_price_ttc'] = $finalPriceTTC;
     $ret['product_final_price_ttc_javascript'] = oledrion_utils::formatFloatForDB($finalPriceTTC);
     $ret['product_final_price_ttc_formated'] = $oledrion_Currency->amountForDisplay($finalPriceTTC);
     $ret['product_final_price_ttc_formated_long'] = $oledrion_Currency->amountForDisplay($finalPriceTTC, 'l');
     $ret['product_vat_amount_formated_long'] = $oledrion_Currency->amountForDisplay($finalPriceHT - $finalPriceTTC);
     $ret['product_tooltip'] = oledrion_utils::makeInfotips($this->getVar('product_description'));
     $ret['product_url_rewrited'] = $this->getLink();
     $ret['product_href_title'] = oledrion_utils::makeHrefTitle($this->getVar('product_title'));
     $ret['product_recommended'] = $this->isRecommended();
     $ret['product_recommended_picture'] = $this->recommendedPicture();
     $ret['product_image_full_url'] = $this->getPictureUrl();
     $ret['product_thumb_full_url'] = $this->getThumbUrl();
     $ret['product_image_full_path'] = $this->getPicturePath();
     $ret['product_thumb_full_path'] = $this->getThumbPath();
     $ret['product_shorten_summary'] = oledrion_utils::truncate_tagsafe($this->getVar('product_summary'), OLEDRION_SUMMARY_MAXLENGTH);
     $ret['product_shorten_description'] = oledrion_utils::truncate_tagsafe($this->getVar('product_description'), OLEDRION_SUMMARY_MAXLENGTH);
     $ret['product_new'] = $this->isNewProduct();
     return $ret;
 }