add product home

This commit is contained in:
Thibault GUILLAUME 2015-09-22 11:47:01 +02:00
parent 4c5ce9ba91
commit 5e376949d9
13 changed files with 5032 additions and 4894 deletions

View File

@ -1,2 +1,2 @@
<?xml version="1.0"?>
<modules_list><modules type="untrusted"><module name="bankwire"/><module name="blockadshooks"/><module name="blockadvertising"/><module name="blockbanner"/><module name="blockbestsellers"/><module name="blockcart"/><module name="blockcategories"/><module name="blockcms"/><module name="blockcmsinfo"/><module name="blockcontact"/><module name="blockcontactinfos"/><module name="blockcurrencies"/><module name="blockcustomerprivacy"/><module name="blocklanguages"/><module name="blocklink"/><module name="blockmanufacturer"/><module name="blockmyaccount"/><module name="blockmyaccountfooter"/><module name="blocknewproducts"/><module name="blocknewsletter"/><module name="blockpaymentlogo"/><module name="blockpermanentlinks"/><module name="blockreinsurance"/><module name="blockrss"/><module name="blocksearch"/><module name="blocksharefb"/><module name="blocksocial"/><module name="blockspecials"/><module name="blockstore"/><module name="blocksupplier"/><module name="blocktags"/><module name="blocktopmenu"/><module name="blockuserinfo"/><module name="blockviewed"/><module name="blockwishlist"/><module name="categorieshome"/><module name="cheque"/><module name="cms_comments"/><module name="cms_extrafields"/><module name="cms_menu"/><module name="cms_pack"/><module name="cmsps"/><module name="cronjobs"/><module name="crossselling"/><module name="dashactivity"/><module name="dashgoals"/><module name="dashproducts"/><module name="dashtrends"/><module name="graphnvd3"/><module name="gridhtml"/><module name="homefeatured"/><module name="homeslider"/><module name="pagesnotfound"/><module name="productcomments"/><module name="productpaymentlogos"/><module name="productscategory"/><module name="producttooltip"/><module name="referralprogram"/><module name="sekeywords"/><module name="sendtoafriend"/><module name="seourl"/><module name="socialsharing"/><module name="vatnumber"/></modules></modules_list>
<modules_list><modules type="untrusted"><module name="bankwire"/><module name="blockadshooks"/><module name="blockadvertising"/><module name="blockbanner"/><module name="blockbestsellers"/><module name="blockcart"/><module name="blockcategories"/><module name="blockcms"/><module name="blockcmsinfo"/><module name="blockcontact"/><module name="blockcontactinfos"/><module name="blockcurrencies"/><module name="blockcustomerprivacy"/><module name="blocklanguages"/><module name="blocklink"/><module name="blockmanufacturer"/><module name="blockmyaccount"/><module name="blockmyaccountfooter"/><module name="blocknewproducts"/><module name="blocknewsletter"/><module name="blockpaymentlogo"/><module name="blockpermanentlinks"/><module name="blockreinsurance"/><module name="blockrss"/><module name="blocksearch"/><module name="blocksharefb"/><module name="blocksocial"/><module name="blockspecials"/><module name="blockstore"/><module name="blocksupplier"/><module name="blocktags"/><module name="blocktopmenu"/><module name="blockuserinfo"/><module name="blockviewed"/><module name="blockwishlist"/><module name="categorieshome"/><module name="cheque"/><module name="cms_comments"/><module name="cms_extrafields"/><module name="cms_menu"/><module name="cms_pack"/><module name="cmsps"/><module name="cronjobs"/><module name="crossselling"/><module name="dashactivity"/><module name="dashgoals"/><module name="dashproducts"/><module name="dashtrends"/><module name="graphnvd3"/><module name="gridhtml"/><module name="homefeatured"/><module name="homeproduct"/><module name="homeslider"/><module name="pagesnotfound"/><module name="productcomments"/><module name="productpaymentlogos"/><module name="productscategory"/><module name="producttooltip"/><module name="referralprogram"/><module name="sekeywords"/><module name="sendtoafriend"/><module name="seourl"/><module name="socialsharing"/><module name="vatnumber"/></modules></modules_list>

View File

@ -372,4 +372,23 @@ class CmsPsPost extends ObjectModel {
return $result;
}
public static function getPostRelationWithProduct($id_product, $limit = 3, $id_lang)
{
$relations = array();
$ids = Db::getInstance()->executeS('
SELECT r.`id_post`
FROM `'._DB_PREFIX_.'cmsps_posts_relation_product` r
LEFT JOIN `'._DB_PREFIX_.'cmsps_posts` c ON(r.`id_post` = c.`id_post`)
WHERE r.`id_product` ='.(int)$id_product.'
ORDER BY c.`note` DESC
LIMIT '.(int)$limit
);
foreach ($ids as $key => $id) {
$relations[] = new CmsPsPost($id['id_post'], $id_lang);
}
return self::injectsData($relations);
}
}

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>homeproduct</name>
<displayName><![CDATA[Display product on Home]]></displayName>
<version><![CDATA[1.0]]></version>
<description><![CDATA[Display product on Home]]></description>
<author><![CDATA[Antadis]]></author>
<tab><![CDATA[front_office_features]]></tab>
<is_configurable>0</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>

View File

@ -0,0 +1,63 @@
<?php
if (!defined('_CAN_LOAD_FILES_'))
exit;
class Homeproduct extends Module
{
public function __construct()
{
$this->name = 'homeproduct';
$this->tab = 'front_office_features';
$this->version = '1.0';
$this->author = 'Antadis';
$this->need_instance = 0;
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('Display product on Home');
$this->description = $this->l('Display product on Home');
$this->secure_key = Tools::encrypt($this->name);
$this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
}
public function install()
{
if (Shop::isFeatureActive())
Shop::setContext(Shop::CONTEXT_ALL);
if (!parent::install()
|| !$this->registerHook('displayHomeProduct')
)
return false;
}
public function hookdisplayHomeProduct($params)
{
$products = self::loadProduct(Context::getContext()->language->id, 2);
$this->smarty->assign(array(
'products' => $products,
));
return $this->display(__FILE__, 'home.tpl');
}
public static function loadProduct($id_lang, $limit)
{
$collection = new Collection('Product', $id_lang);
$collection->where('active', '=', 1);
$collection->where('online_only', '=', 1);
$collection->where('online_only', '=', 1);
$collection->setPageSize($limit);
$products = $collection->getResults();
$products = array_map(function($elem) {
$elem = $elem->loadReductionInfo();
return get_object_vars($elem);
}, $products);
return $products;
}
}

View File

@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@ -0,0 +1,4 @@
<img src="{$img_dir}logo_shopping.png" alt="{l s='Shopping Tout Pratique' mod='homeproduct'}" class="img-responsive">
<div class="product_home row">
{include file="$tpl_dir./product-list.tpl" products=$products position=6}
</div>

View File

@ -18,6 +18,11 @@ class Product extends ProductCore
}
$this->category = Category::getLinkRewrite((int)$this->id_category_default, (int)$id_lang);
$this->link = Context::getContext()->link->getProductLink($this);
$this->id_product = $this->id;
$id_image = Product::getCover($this->id);
$this->id_image = $id_image['id_image'];
if (self::$_taxCalculationMethod == PS_TAX_EXC)
{

View File

@ -357,6 +357,12 @@ body .ac_results {
.center_home {
margin-bottom: 30px;
}
.product_home {
padding-top: 15px;
}
.product_home .product-container:last-child {
border-right: 0;
}
.video_home {
border-top: 3px solid #333333;

View File

@ -73,10 +73,7 @@
<div class="row center_home">
<div class="col-sm-4">
<img src="{$img_dir}logo_shopping.png" alt="{l s='Shopping Tout Pratique'}" class="img-responsive">
<div class="product_home">
HOOK PRODUIT EN REMONTE HOME
</div>
{hook h='displayHomeProduct'}
</div>
<div class="col-sm-8">
{hook h='displayHomeVideo'}
@ -91,7 +88,6 @@
{/foreach}
</div>
<div class="row">
{hook h="displayHomeBottom"}
</div>

View File

@ -25,7 +25,7 @@
*}
<h2>{l s='Produits les plus populaires' mod='blockbestsellers'}</h2>
{if isset($best_sellers) && $best_sellers}
{include file="$tpl_dir./product-list.tpl" products=$best_sellers class='blockbestsellers tab-pane' id='blockbestsellers' position='homestore'}
{include file="$tpl_dir./product-list.tpl" products=$best_sellers class='blockbestsellers tab-pane' id='blockbestsellers' position=2}
{else}
<ul id="blockbestsellers" class="blockbestsellers tab-pane">
<li class="alert alert-info">{l s='No best sellers at this time.' mod='blockbestsellers'}</li>

View File

@ -4,7 +4,7 @@
{foreach from=$products item=product name=products key=key}
{if (isset($nbProduct) && $key < $nbProduct) || !isset($nbProduct)}
<div class="product-container col-md-{if isset($position)}2{else}3{/if} col-sm-4 col-xs-6 col-xxs-12" itemscope itemtype="http://schema.org/Product">
<div class="product-container col-md-{if isset($position)}{$position}{else}3{/if} col-sm-4 col-xs-6 col-xxs-12" itemscope itemtype="http://schema.org/Product">
<div class="border {if isset($percentReduction) && $percentReduction > 0} discount{/if}">
{if $product.specific_prices.reduction_type == 'percentage'}
<span class="price-percent-reduction">-{$product.specific_prices.reduction * 100}%</span>
@ -44,7 +44,7 @@
<!-- Ajout panier -->
<div class="add_to_cart_contain">
<a class="btn ajax_add_to_cart_button" data-id-product="{$product.id_product}" data-minimal_quantity="1">
<i class="icon icon-shopping-cart"></i> {l s='J\'achete'}
<i class="icon icon-shopping-cart"></i> <span>{l s='J\'achete'}</span>
</a>
</div>

Binary file not shown.

File diff suppressed because it is too large Load Diff