Esempio n. 1
0
    $main_image = $localization->getMainImage();
    ?>
				
	<div class="col-xs-12">
	                    <div class="aside-feature">
	                        <div class="row">
	                            <div class="col-md-2">
	                                <div class="img-feature">
	                                    <a href="<?php 
    echo $product_url;
    ?>
"><img src="<?php 
    if ($main_image) {
        echo $main_image->getImageUrl(120, 120);
    } else {
        echo ProductImage::placehoderForSize(120, 120);
    }
    ?>
" class=" img-thumbnail center-block" alt=""></a>
	                                </div>
	                            </div>
	                            <div class="col-md-10">
									<p><a href="<?php 
    echo $product_url;
    ?>
" class="strong"><?php 
    echo $localization->name;
    ?>
</a><span class="pull-right"><strong><i class="fa fa-star"></i> <?php 
    echo Yii::t("app", "En vedette");
    ?>
Esempio n. 2
0
    $mainImage = $localization->getMainImage();
    if ($mainImage) {
        echo $mainImage->getImageURL(300, 280);
    } else {
        echo ProductImage::placehoderForSize(300, 280);
    }
    ?>
" alt="<?php 
    echo $localization->name;
    ?>
" class="img-responsive center-block hidden-xs hidden-sm">
				<img alt="" src="<?php 
    if ($mainImage) {
        echo $mainImage->getImageURL(600, 560);
    } else {
        echo ProductImage::placehoderForSize(600, 560);
    }
    ?>
" alt="<?php 
    echo $localization->name;
    ?>
" class="img-responsive center-block visible-xs-block visible-sm-block">
						</a>
            <?php 
    $brand = $product->brand;
    if ($brand) {
        ?>
<span class="date-over"><strong><?php 
        $brand_localization = $brand->localizationForLanguage(Yii::app()->language, $accept_substitute = true);
        echo CHtml::link($brand_localization->name, $this->createUrl("category/view", array("slug" => $brand_localization->slug)));
        ?>
Esempio n. 3
0
 /**
  * Currently reduced products
  * When the output is set to iframe, styling will be added so the layout is self contained.
  */
 public function actionRebates($format = "html", $limit = 4, $offset = 0, $background = "default", $version = 1, $pretty = 0)
 {
     if (!is_numeric($limit) || !is_numeric($offset) || !is_numeric($version) || !is_numeric($pretty)) {
         throw new CHttpException(400, 'A numeric value was expected.');
     }
     if ($limit > 32 || $offset > 32) {
         throw new CHttpException(400, 'Offset and limit can\'t be larger than 32. If you need to retrieve a large amount of products efficiently, please refer to Boukem\'s API documentation.');
     }
     $cache_id = "WidgetController:[promotionsForLanguage] " . md5(Yii::app()->language . CHtml::encode($background) . CHtml::encode($format) . " " . $limit . " " . $offset);
     $cache_duration = 120;
     //10800;
     $content = Yii::app()->cache->get($cache_id);
     if (!$content) {
         $rebatesDataProvider = new CActiveDataProvider('ProductRebate', array('criteria' => array('order' => "valid_until", 'limit' => $limit, 'offset' => $offset, 'with' => array('product', 'product.productLocalization')), 'pagination' => false));
         if ($format === "html") {
             if ($background != "transparent" && $background != "default") {
                 $background = $this->validate_html_color($background);
             }
             $content = $this->renderPartial('_rebates', array('rebates' => $rebatesDataProvider, "background" => $background), true);
         } else {
             if ($format === "json") {
                 $content = array();
                 foreach ($rebatesDataProvider->getData() as $rebate) {
                     $product = $rebate->product;
                     $localization = $product->localizationForLanguage(Yii::app()->language, $accept_substitute = false);
                     if ($product && $localization && $product->visible && !$product->discontinued) {
                         $product_url = $this->createAbsoluteUrl("product/view", array('slug' => $localization->slug));
                         $currentPrice = $product->getCurrentPrice();
                         $regularPrice = $product->price;
                         if ($currentPrice == $regularPrice) {
                             $isOnSale = false;
                             $rebatePercent = 0;
                         } else {
                             $isOnSale = true;
                             $rebatePercent = round(($regularPrice - $currentPrice) / $regularPrice * 100, $precision = 0, $mode = PHP_ROUND_HALF_DOWN);
                         }
                         // Assemble a dictionary with the values
                         $main_image = $localization->getMainImage();
                         $image_dict = array();
                         if ($main_image) {
                             $image_dict["thumbnail_50"] = $main_image->getImageUrl(50, 50);
                             $image_dict["thumbnail_250"] = $main_image->getImageUrl(250, 250);
                             $image_dict["thumbnail_500"] = $main_image->getImageUrl(500, 500);
                             $image_dict["thumbnail_1000"] = $main_image->getImageUrl(1000, 1000);
                             $image_dict["is_placeholder"] = false;
                         } else {
                             $image_dict["thumbnail_50"] = ProductImage::placehoderForSize(50, 50);
                             $image_dict["thumbnail_250"] = ProductImage::placehoderForSize(250, 250);
                             $image_dict["thumbnail_350"] = ProductImage::placehoderForSize(350, 350);
                             $image_dict["thumbnail_500"] = ProductImage::placehoderForSize(500, 500);
                             $image_dict["thumbnail_1000"] = ProductImage::placehoderForSize(1000, 1000);
                             $image_dict["is_placeholder"] = true;
                         }
                         $product_dict = array("id" => $product->id, "image" => $image_dict, "name" => $localization->name, "description" => $localization->short_description, "url" => $product_url, "current_price" => $currentPrice, "regular_price" => $regularPrice, "is_on_sale" => $isOnSale, "rebate_percent" => $rebatePercent);
                         $content[] = $product_dict;
                     }
                 }
             } else {
                 $content = array();
             }
         }
         Yii::app()->cache->set($cache_id, $content, $cache_duration);
     }
     if ($format === "html") {
         echo $content;
     } else {
         if ($format === "json") {
             header('Access-Control-Allow-Origin: *');
             $this->renderJson($content, $pretty = $pretty);
         } else {
             throw new CHttpException(400, 'The format parameter is invalid.');
         }
     }
 }
Esempio n. 4
0
/* @var $this CartController
   @var $data OrderHasProduct
 */
$product = $data->product;
$localizationForProduct = $product->localizationForLanguage(Yii::app()->language, $accept_substitute = true);
?>

<tr data-product="<?php 
echo $product->id;
?>
">

		<td class="hidden-xs"><img src="<?php 
$image = $localizationForProduct->getMainImage();
echo $image ? $image->getImageURL(150, 150) : ProductImage::placehoderForSize(150, 150);
?>
" class="img-center" alt=""></td>
    <td><?php 
echo CHtml::link($localizationForProduct->name, array("product/view", 'slug' => $localizationForProduct->slug));
?>
</td>
    <td><?php 
if (Yii::app()->language === "fr") {
    echo CHtml::encode($data->price_paid) . " \$";
} else {
    echo "\$ " . CHtml::encode($data->price_paid);
}
?>
</td>
    <td class="col-md-3">
Esempio n. 5
0
 public function getPrintableOrderItemsArray()
 {
     $dataProvider = new CActiveDataProvider('OrderHasProduct', array('criteria' => array('condition' => 'order_id=' . $this->id, 'with' => array('product')), 'pagination' => false));
     $output_array = array();
     foreach ($dataProvider->getData() as $item) {
         $cartitem = array('quantity' => $item->quantity, 'price_paid' => $item->price_paid, 'product_id' => $item->product_id);
         $product = $item->product;
         $localization = $product->localizationForLanguage(Yii::app()->language, $accept_substitute = true);
         $image = $localization->getMainImage();
         $cartitem['name'] = $localization->name;
         $cartitem['slug'] = $localization->slug;
         $cartitem['thumbnail'] = $image ? $image->getImageURL(50, 50) : ProductImage::placehoderForSize(50, 50);
         $cartitem['thumbnail_lg'] = $image ? $image->getImageURL(120, 160) : ProductImage::placehoderForSize(120, 160);
         $cartitem['link'] = Yii::app()->createUrl('product/view', array('slug' => $localization->slug));
         $output_array[] = $cartitem;
     }
     return $output_array;
 }
Esempio n. 6
0
}
?>
                            
                            
				                        </ul>
				                    </div>
				                </div> <!-- Right column -->
				
                <div class="col-md-8 col-md-pull-4">
                	<div class="row">
                    	<div class="col-md-12">
                        	<div class="w-box blog-post">
                                <figure>
                                    <img alt="" itemprop="image" src="<?php 
$image = $localization->getMainImage();
echo $image ? $image->getImageURL(700, 500) : ProductImage::placehoderForSize(700, 500);
?>
" class="img-responsive center-block hidden-xs">
                                    
									
									<?php 
if ($kemProduct->localization->custom_description) {
    ?>
									</figure> <!-- Image figure -->
								</div><!-- blog post -->
								
								<div class="w-box inner">
                	
								                                <div class="comments-wr">
								                                	<h2><?php 
    echo Yii::t("app", "La suggestion de {name}", array("{name}" => $kemProduct->localization->custom_description->author_name));
        $isOnSale = true;
        $rebatePercent = round(($regularPrice - $currentPrice) / $regularPrice * 100, $precision = 0, $mode = PHP_ROUND_HALF_DOWN);
    }
    ?>
	
	
	<div class="col-xs-6 col-sm-4 col-md-3 text-center dense_product">
		
		<a href="<?php 
    echo $product_url;
    ?>
"><img alt="" src="<?php 
    if ($main_image) {
        echo $main_image->getImageUrl(160, 160, $fit = ProductImage::FIT_HEIGHT);
    } else {
        echo ProductImage::placehoderForSize(160, 160);
    }
    ?>
" alt="<?php 
    echo $localization->name;
    ?>
" class=" center-block"></a>
		<?php 
    if ($isOnSale) {
        ?>
			<div class="rebatebadge"><span class="animated tada">-<?php 
        echo $rebatePercent;
        ?>
%</span></div>
		<?php 
    }
Esempio n. 8
0
$brand_localization = $brand->localizationForLanguage(Yii::app()->language, $accept_substitute = true);
$main_image = $localization->getMainImage();
?>

<tr>
	<td class="hidden-xs">
		
        <a href="<?php 
echo $product_url;
?>
">
			<img alt="" src="<?php 
if ($main_image) {
    echo $main_image->getImageUrl(50, 50);
} else {
    echo ProductImage::placehoderForSize(50, 50);
}
?>
" alt="<?php 
echo $localization->name;
?>
" class="img-responsive center-block">
			
					</a>
		</td>
		<td>
			<strong><a href="<?php 
echo $product_url;
?>
"><?php 
echo $localization->name;
} else {
    $isOnSale = true;
    $rebatePercent = round(($regularPrice - $currentPrice) / $regularPrice * 100, $precision = 0, $mode = PHP_ROUND_HALF_DOWN);
}
?>
<li class="col-xs-12 col-sm-6 col-md-3"><figure class="card">
  <a href="<?php 
echo $product_url;
?>
" target="_parent">
	  
<img alt="" class="center-block" src="<?php 
if ($main_image) {
    echo $main_image->getImageUrl(125, 125, $fit = ProductImage::FIT_HEIGHT);
} else {
    echo ProductImage::placehoderForSize(125, 125);
}
?>
" alt="<?php 
echo $localization->name;
?>
">
	<?php 
if ($isOnSale) {
    ?>
<div class="rebatebadge">-<?php 
    echo $rebatePercent;
    ?>
%</div><?php 
}
?>
Esempio n. 10
0
 /**
  * Returns an array of the current product with the current language description. Will always use an alternative language if necessary.
  * Use this function to serialize the product into JSON
  * @return str the static model as a json dict.
  */
 public function getStructuredProductArray()
 {
     $cache_id = $this->getProductArrayCacheIdForLanguage(Yii::app()->language);
     $cache_duration = 300;
     //10800;
     $productArray = Yii::app()->cache->get($cache_id);
     if (!$productArray) {
         $localization = $this->localizationForLanguage(Yii::app()->language, $accept_substitute = true);
         if ($localization === null) {
             return null;
         }
         $is_product_available_in_current_language = true;
         if ($this->productLocalization === null) {
             $is_product_available_in_current_language = false;
         }
         $productArray = array("price" => floatval($this->getCurrentPrice()), "available_in_current_language" => $is_product_available_in_current_language, "name" => $localization->name, "short_description" => $localization->short_description, "long_description" => $localization->long_description, "visible" => $this->visible == 1 ? true : false, "taxable" => $this->taxable == 1 ? true : false, "weight" => floatval($this->weight), "discontinued" => $this->discontinued == 1 ? true : false, "barcode" => $this->barcode, "parent_id" => $this->parent_product_id, "sku" => $this->sku, "product_id" => intval($this->id), "localization_id" => intval($localization->id), "slug" => $localization->slug, "categories" => array());
         // Load the videos
         $productArray["videos"] = $this->getVideosForLanguage(Yii::app()->language);
         // Find the brand
         $brand = $this->brand;
         $brand_localization = $this->brand->localizationForLanguage(Yii::app()->language, $accept_substitute = true);
         $productArray["brand"] = array("id" => intval($this->brand_id), "name" => $brand_localization ? $brand_localization->name : null, "visible" => $brand ? $brand->visible == 1 ? true : false : false);
         $main_image = $localization->getMainImage();
         $productArray["image"] = array("id" => null, "extension" => null, "locale_id" => null, "small" => ProductImage::placehoderForSize(200, 200), "large" => ProductImage::placehoderForSize(800, 800), "base_url" => ProductImage::getImageGeneratorBaseUrl());
         if ($main_image !== null) {
             $productArray["image"]["id"] = intval($main_image->identifier);
             $productArray["image"]["extension"] = $main_image->extension;
             $productArray["image"]["locale_id"] = $main_image->locale_id;
             $productArray["image"]["small"] = $main_image->getImageURL(200, 200);
             $productArray["image"]["large"] = $main_image->getImageURL(800, 800);
         }
         // Loop through the categories to return the appropriate product categories
         foreach ($this->categories as $category) {
             $category_localization = $category->localizationForLanguage(Yii::app()->language, $accept_substitute = false);
             if ($category_localization !== null) {
                 $productArray["categories"][] = array("id" => intval($category->id), "name" => $localization->name, "visible" => $category->visible == 1 ? true : false);
             }
         }
         Yii::app()->cache->set($cache_id, $productArray, $cache_duration);
     }
     return $productArray;
 }