first commit
This commit is contained in:
153
modules/leofeature/classes/CompareProduct.php
Normal file
153
modules/leofeature/classes/CompareProduct.php
Normal file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Leotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Leo feature for prestashop 1.7: ajax cart, review, compare, wishlist at product list
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author leotheme <leotheme@gmail.com>
|
||||
* @copyright 2007-2015 Leotheme
|
||||
* @license http://leotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class CompareProduct extends ObjectModel
|
||||
{
|
||||
public $id_compare;
|
||||
|
||||
public $id_customer;
|
||||
|
||||
public $date_add;
|
||||
|
||||
public $date_upd;
|
||||
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
*/
|
||||
public static $definition = array(
|
||||
'table' => 'leofeature_compare',
|
||||
'primary' => 'id_compare',
|
||||
'fields' => array(
|
||||
'id_compare' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
|
||||
'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Get all compare products of the customer
|
||||
* @param int $id_customer
|
||||
* @return array
|
||||
*/
|
||||
public static function getCompareProducts($id_compare)
|
||||
{
|
||||
$results = Db::getInstance()->executeS('
|
||||
SELECT DISTINCT `id_product`
|
||||
FROM `'._DB_PREFIX_.'leofeature_compare` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'leofeature_compare_product` cp ON (cp.`id_compare` = c.`id_compare`)
|
||||
WHERE cp.`id_compare` = '.(int)($id_compare));
|
||||
|
||||
$compareProducts = array();
|
||||
|
||||
if ($results) {
|
||||
foreach ($results as $result) {
|
||||
$compareProducts[] = (int)$result['id_product'];
|
||||
}
|
||||
}
|
||||
|
||||
return $compareProducts;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a compare product for the customer
|
||||
* @param int $id_customer, int $id_product
|
||||
* @return bool
|
||||
*/
|
||||
public static function addCompareProduct($id_compare, $id_product)
|
||||
{
|
||||
// Check if compare row exists
|
||||
$id_compare = Db::getInstance()->getValue('SELECT `id_compare`
|
||||
FROM `'._DB_PREFIX_.'leofeature_compare`
|
||||
WHERE `id_compare` = '.(int)$id_compare);
|
||||
|
||||
if (!$id_compare) {
|
||||
$id_customer = false;
|
||||
if (Context::getContext()->customer) {
|
||||
$id_customer = Context::getContext()->customer->id;
|
||||
}
|
||||
$sql = Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'leofeature_compare` (`id_compare`, `id_customer`) VALUES (NULL, "'.($id_customer ? (int)$id_customer: '0').'")');
|
||||
if ($sql) {
|
||||
$id_compare = Db::getInstance()->getValue('SELECT MAX(`id_compare`) FROM `'._DB_PREFIX_.'leofeature_compare`');
|
||||
Context::getContext()->cookie->id_compare = $id_compare;
|
||||
}
|
||||
}
|
||||
|
||||
return Db::getInstance()->execute('
|
||||
INSERT IGNORE INTO `'._DB_PREFIX_.'leofeature_compare_product` (`id_compare`, `id_product`, `date_add`, `date_upd`)
|
||||
VALUES ('.(int)($id_compare).', '.(int)($id_product).', NOW(), NOW())');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a compare product for the customer
|
||||
* @param int $id_compare
|
||||
* @param int $id_product
|
||||
* @return bool
|
||||
*/
|
||||
public static function removeCompareProduct($id_compare, $id_product)
|
||||
{
|
||||
return Db::getInstance()->execute('
|
||||
DELETE cp FROM `'._DB_PREFIX_.'leofeature_compare_product` cp, `'._DB_PREFIX_.'leofeature_compare` c
|
||||
WHERE cp.`id_compare`=c.`id_compare`
|
||||
AND cp.`id_product` = '.(int)$id_product.'
|
||||
AND c.`id_compare` = '.(int)$id_compare);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of compare products of the customer
|
||||
* @param int $id_compare
|
||||
* @return int
|
||||
*/
|
||||
public static function getNumberProducts($id_compare)
|
||||
{
|
||||
return (int)(Db::getInstance()->getValue('SELECT count(`id_compare`)
|
||||
FROM `'._DB_PREFIX_.'leofeature_compare_product`
|
||||
WHERE `id_compare` = '.(int)($id_compare)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clean entries which are older than the period
|
||||
* @param string $period
|
||||
* @return void
|
||||
*/
|
||||
public static function cleanCompareProducts($period = null)
|
||||
{
|
||||
if ($period !== null) {
|
||||
Tools::displayParameterAsDeprecated('period');
|
||||
}
|
||||
|
||||
Db::getInstance()->execute('
|
||||
DELETE cp, c FROM `'._DB_PREFIX_.'leofeature_compare_product` cp, `'._DB_PREFIX_.'leofeature_compare` c
|
||||
WHERE cp.date_upd < DATE_SUB(NOW(), INTERVAL 1 WEEK) AND c.`id_compare`=cp.`id_compare`');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the id_compare by id_customer
|
||||
* @param int $id_customer
|
||||
* @return int $id_compare
|
||||
*/
|
||||
public static function getIdCompareByIdCustomer($id_customer)
|
||||
{
|
||||
return (int)Db::getInstance()->getValue('SELECT `id_compare`
|
||||
FROM `'._DB_PREFIX_.'leofeature_compare`
|
||||
WHERE `id_customer`= '.(int)$id_customer);
|
||||
}
|
||||
}
|
||||
230
modules/leofeature/classes/LeoProductAttribute.php
Normal file
230
modules/leofeature/classes/LeoProductAttribute.php
Normal file
@@ -0,0 +1,230 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Leotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Leo feature for prestashop 1.7: ajax cart, review, compare, wishlist at product list
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author leotheme <leotheme@gmail.com>
|
||||
* @copyright 2007-2015 Leotheme
|
||||
* @license http://leotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class LeoProductAttribute
|
||||
{
|
||||
public function getReqQuantity($product) {
|
||||
$quantity = (int)$this->getMinimalQuantity($product);
|
||||
if ($quantity < $product['minimal_quantity']) {
|
||||
$quantity = $product['minimal_quantity'];
|
||||
}
|
||||
return $quantity;
|
||||
}
|
||||
|
||||
public function getMinimalQuantity($product) {
|
||||
$minimalQuantity = 1;
|
||||
if ($product['id_product_attribute']) {
|
||||
$combination = $this->getCombinationsByID($product['id_product_attribute'], $product['id']);
|
||||
if ($combination['minimal_quantity']) {
|
||||
$minimalQuantity = $combination['minimal_quantity'];
|
||||
}
|
||||
} else {
|
||||
$minimalQuantity = $product['minimal_quantity'];
|
||||
}
|
||||
return $minimalQuantity;
|
||||
}
|
||||
|
||||
public function getCombinationsByID($combinationId, $productId) {
|
||||
$product = new Product((int)$productId);
|
||||
$findedCombination = null;
|
||||
$combinations = $product->getAttributesGroups(Context::getContext()->language->id);
|
||||
foreach ($combinations as $combination) {
|
||||
if ((int) ($combination['id_product_attribute']) === $combinationId) {
|
||||
$findedCombination = $combination;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $findedCombination;
|
||||
}
|
||||
|
||||
public static function getProductAttributesID($productId, $attributesId) {
|
||||
if (!is_array($attributesId)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$productAttributeId = Db::getInstance()->getValue('
|
||||
SELECT pac.`id_product_attribute`
|
||||
FROM `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||
INNER JOIN `'._DB_PREFIX_.'product_attribute` pa ON pa.id_product_attribute = pac.id_product_attribute
|
||||
WHERE id_product = '.(int)$productId.' AND id_attribute IN ('.implode(',', array_map('intval', $attributesId)).')
|
||||
GROUP BY id_product_attribute
|
||||
HAVING COUNT(id_product) = '.count($attributesId));
|
||||
|
||||
if ($productAttributeId === false) {
|
||||
$ordered = array();
|
||||
$result = Db::getInstance()->executeS('SELECT `id_attribute` FROM `'._DB_PREFIX_.'attribute` a
|
||||
INNER JOIN `'._DB_PREFIX_.'attribute_group` g ON a.`id_attribute_group` = g.`id_attribute_group`
|
||||
WHERE `id_attribute` IN ('.implode(',', array_map('intval', $attributesId)).') ORDER BY g.`position` ASC');
|
||||
|
||||
foreach ($result as $row) {
|
||||
$ordered[] = $row['id_attribute'];
|
||||
}
|
||||
|
||||
while ($productAttributeId === false && count($ordered) > 0) {
|
||||
array_pop($ordered);
|
||||
$productAttributeId = Db::getInstance()->getValue('
|
||||
SELECT pac.`id_product_attribute`
|
||||
FROM `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||
INNER JOIN `'._DB_PREFIX_.'product_attribute` pa ON pa.id_product_attribute = pac.id_product_attribute
|
||||
WHERE id_product = '.(int)$productId.' AND id_attribute IN ('.implode(',', array_map('intval', $ordered)).')
|
||||
GROUP BY id_product_attribute
|
||||
HAVING COUNT(id_product) = '.count($ordered));
|
||||
}
|
||||
}
|
||||
return $productAttributeId;
|
||||
}
|
||||
|
||||
public static function getAttributesParams($productId, $productAttributeId) {
|
||||
$langId = (int)Context::getContext()->language->id;
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT a.`id_attribute`, a.`id_attribute_group`
|
||||
FROM `'._DB_PREFIX_.'attribute` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al
|
||||
ON (al.`id_attribute` = a.`id_attribute` AND al.`id_lang` = '.(int)$langId.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||
ON (pac.`id_attribute` = a.`id_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
|
||||
ON (pa.`id_product_attribute` = pac.`id_product_attribute`)
|
||||
'.Shop::addSqlAssociation('product_attribute', 'pa').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl
|
||||
ON (a.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)$langId.')
|
||||
WHERE pa.`id_product` = '.(int)$productId.'
|
||||
AND pac.`id_product_attribute` = '.(int)$productAttributeId.'
|
||||
AND agl.`id_lang` = '.(int)$langId);
|
||||
}
|
||||
|
||||
public static function getProductCombinationsSeparatelly($idProduct, $idProductAttribute) {
|
||||
$product = new Product((int)$idProduct, true, (int)Context::getContext()->language->id, (int)Context::getContext()->shop->id);
|
||||
$attributes = self::getAttributesParams((int)$idProduct, (int)$idProductAttribute);
|
||||
$productAttributes = array();
|
||||
foreach ($attributes as $attribute) {
|
||||
$productAttributes['attributes'][$attribute['id_attribute_group']] = $attribute;
|
||||
}
|
||||
$groups = array();
|
||||
$attributesGroups = $product->getAttributesGroups(Context::getContext()->language->id);
|
||||
if (is_array($attributesGroups) && $attributesGroups) {
|
||||
foreach ($attributesGroups as $k => $row) {
|
||||
if (!isset($groups[$row['id_attribute_group']])) {
|
||||
$groups[$row['id_attribute_group']] = array(
|
||||
'group_name' => $row['group_name'],
|
||||
'name' => $row['public_group_name'],
|
||||
'group_type' => $row['group_type'],
|
||||
'default' => -1,
|
||||
);
|
||||
}
|
||||
$groups[$row['id_attribute_group']]['attributes'][$row['id_attribute']] = array(
|
||||
'name' => $row['attribute_name'],
|
||||
'html_color_code' => $row['attribute_color'],
|
||||
'texture' => (@filemtime(_PS_COL_IMG_DIR_.$row['id_attribute'].'.jpg')) ? _THEME_COL_DIR_.$row['id_attribute'].'.jpg' : '',
|
||||
'selected' => (isset($productAttributes['attributes'][$row['id_attribute_group']]['id_attribute']) && $productAttributes['attributes'][$row['id_attribute_group']]['id_attribute'] == $row['id_attribute']) ? true : false,
|
||||
);
|
||||
if ($row['default_on'] && $groups[$row['id_attribute_group']]['default'] == -1) {
|
||||
$groups[$row['id_attribute_group']]['default'] = (int) $row['id_attribute'];
|
||||
}
|
||||
if (!isset($groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']])) {
|
||||
$groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] = 0;
|
||||
}
|
||||
$groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] += (int) $row['quantity'];
|
||||
}
|
||||
$currentSelectedAttributes = array();
|
||||
$count = 0;
|
||||
foreach ($groups as &$group) {
|
||||
$count++;
|
||||
if ($count > 1) {
|
||||
$attributesId = Db::getInstance()->executeS('SELECT `id_attribute` FROM `'._DB_PREFIX_.'product_attribute_combination` pac2
|
||||
INNER JOIN (
|
||||
SELECT pac.`id_product_attribute`
|
||||
FROM `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||
INNER JOIN `'._DB_PREFIX_.'product_attribute` pa ON pa.id_product_attribute = pac.id_product_attribute
|
||||
WHERE id_product = '.(int)$product->id.' AND id_attribute IN ('.implode(',', array_map('intval', $currentSelectedAttributes)).')
|
||||
GROUP BY id_product_attribute
|
||||
HAVING COUNT(id_product) = '.count($currentSelectedAttributes).'
|
||||
)pac on pac.`id_product_attribute` = pac2.`id_product_attribute`
|
||||
AND id_attribute NOT IN ('.implode(',', array_map('intval', $currentSelectedAttributes)).')');
|
||||
foreach ($attributesId as $k => $row) {
|
||||
$attributesId[$k] = (int)$row['id_attribute'];
|
||||
}
|
||||
foreach ($group['attributes'] as $key => $attribute) {
|
||||
if (!in_array((int)$key, $attributesId)) {
|
||||
unset($group['attributes'][$key]);
|
||||
unset($group['attributes_quantity'][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$index = 0;
|
||||
$currentSelectedAttribute = 0;
|
||||
foreach ($group['attributes'] as $key => $attribute) {
|
||||
if ($index === 0) {
|
||||
$currentSelectedAttribute = $key;
|
||||
}
|
||||
if ($attribute['selected']) {
|
||||
$currentSelectedAttribute = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($currentSelectedAttribute > 0) {
|
||||
$currentSelectedAttributes[] = $currentSelectedAttribute;
|
||||
}
|
||||
}
|
||||
if (!Product::isAvailableWhenOutOfStock($product->out_of_stock) && Configuration::get('PS_DISP_UNAVAILABLE_ATTR') == 0) {
|
||||
foreach ($groups as &$group) {
|
||||
foreach ($group['attributes_quantity'] as $key => &$quantity) {
|
||||
if ($quantity <= 0) {
|
||||
unset($group['attributes'][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $groups;
|
||||
}
|
||||
|
||||
public static function getProductCombinationsList($productID, $showOutOfStock, $idProductAttribute = 0) {
|
||||
$product = new Product($productID);
|
||||
$combinations = $product->getAttributeCombinations((int)Context::getContext()->language->id);
|
||||
$productsVariants = array();
|
||||
if (is_array($combinations)) {
|
||||
foreach ($combinations as $k => $combination) {
|
||||
if ((!$showOutOfStock && (int)$combination['quantity'] > 0) || $showOutOfStock) {
|
||||
$productsVariants[$combination['id_product_attribute']]['id_product_attribute'] = $combination['id_product_attribute'];
|
||||
$productsVariants[$combination['id_product_attribute']]['attributes'][] = array($combination['group_name'], $combination['attribute_name'], $combination['id_attribute'], $combination['id_attribute_group']);
|
||||
$productsVariants[$combination['id_product_attribute']]['price'] = $product->getPrice(true, $combination['id_product_attribute'], (int)Configuration::get('PS_PRICE_DISPLAY_PRECISION'));
|
||||
if ($idProductAttribute > 0) {
|
||||
$productsVariants[$combination['id_product_attribute']]['default_on'] = ($idProductAttribute == $combination['id_product_attribute']);
|
||||
} else {
|
||||
$productsVariants[$combination['id_product_attribute']]['default_on'] = $combination['default_on'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($productsVariants)) {
|
||||
foreach ($productsVariants as $id_product_attribute => $product_attribute) {
|
||||
$list = '';
|
||||
asort($product_attribute['attributes']);
|
||||
foreach ($product_attribute['attributes'] as $attribute) {
|
||||
$list .= $attribute[0].' - '.$attribute[1].', ';
|
||||
}
|
||||
$list = rtrim($list, ', ');
|
||||
$productsVariants[$id_product_attribute]['name'] = $list;
|
||||
}
|
||||
}
|
||||
return $productsVariants;
|
||||
}
|
||||
}
|
||||
185
modules/leofeature/classes/LeofeatureProduct.php
Normal file
185
modules/leofeature/classes/LeofeatureProduct.php
Normal file
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Leotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Leo feature for prestashop 1.7: ajax cart, review, compare, wishlist at product list
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author leotheme <leotheme@gmail.com>
|
||||
* @copyright 2007-2015 Leotheme
|
||||
* @license http://leotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
use PrestaShop\PrestaShop\Adapter\Product\PriceFormatter;
|
||||
use PrestaShop\PrestaShop\Adapter\Image\ImageRetriever;
|
||||
use PrestaShop\PrestaShop\Core\Product\ProductExtraContentFinder;
|
||||
use PrestaShop\PrestaShop\Core\Product\ProductListingPresenter;
|
||||
use PrestaShop\PrestaShop\Adapter\Product\ProductColorsRetriever;
|
||||
use PrestaShop\PrestaShop\Core\Addon\Module\ModuleManagerBuilder;
|
||||
|
||||
class LeofeatureProduct extends ProductControllerCore
|
||||
{
|
||||
|
||||
protected function assignPriceAndTax()
|
||||
{
|
||||
$id_customer = (isset($this->context->customer) ? (int) $this->context->customer->id : 0);
|
||||
$id_group = (int) Group::getCurrent()->id;
|
||||
$id_country = $id_customer ? (int) Customer::getCurrentCountry($id_customer) : (int) Tools::getCountry();
|
||||
|
||||
// Tax
|
||||
$tax = (float) $this->product->getTaxesRate(new Address((int) $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
$this->context->smarty->assign('tax_rate', $tax);
|
||||
|
||||
$product_price_with_tax = Product::getPriceStatic($this->product->id, true, null, 6);
|
||||
if (Product::$_taxCalculationMethod == PS_TAX_INC) {
|
||||
$product_price_with_tax = Tools::ps_round($product_price_with_tax, 2);
|
||||
}
|
||||
|
||||
$id_currency = (int) $this->context->cookie->id_currency;
|
||||
$id_product = (int) $this->product->id;
|
||||
$id_product_attribute = Tools::getValue('id_product_attribute', null);
|
||||
$id_shop = $this->context->shop->id;
|
||||
|
||||
$quantity_discounts = SpecificPrice::getQuantityDiscounts($id_product, $id_shop, $id_currency, $id_country, $id_group, $id_product_attribute, false, (int) $this->context->customer->id);
|
||||
foreach ($quantity_discounts as &$quantity_discount) {
|
||||
if ($quantity_discount['id_product_attribute']) {
|
||||
$combination = new Combination((int) $quantity_discount['id_product_attribute']);
|
||||
$attributes = $combination->getAttributesName((int) $this->context->language->id);
|
||||
foreach ($attributes as $attribute) {
|
||||
$quantity_discount['attributes'] = $attribute['name'].' - ';
|
||||
}
|
||||
$quantity_discount['attributes'] = rtrim($quantity_discount['attributes'], ' - ');
|
||||
}
|
||||
if ((int) $quantity_discount['id_currency'] == 0 && $quantity_discount['reduction_type'] == 'amount') {
|
||||
$quantity_discount['reduction'] = Tools::convertPriceFull($quantity_discount['reduction'], null, Context::getContext()->currency);
|
||||
}
|
||||
}
|
||||
|
||||
$product_price = $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false);
|
||||
$this->quantity_discounts = $this->formatQuantityDiscounts($quantity_discounts, $product_price, (float) $tax, $this->product->ecotax);
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'no_tax' => Tax::excludeTaxeOption() || !$tax,
|
||||
'tax_enabled' => Configuration::get('PS_TAX') && !Configuration::get('AEUC_LABEL_TAX_INC_EXC'),
|
||||
'customer_group_without_tax' => Group::getPriceDisplayMethod($this->context->customer->id_default_group),
|
||||
));
|
||||
}
|
||||
|
||||
public function getTemplateVarProduct2($id_product, $id_product_attribute)
|
||||
{
|
||||
if ($id_product) {
|
||||
$this->product = new Product($id_product, true, $this->context->language->id, $this->context->shop->id);
|
||||
}
|
||||
|
||||
if (!Validate::isLoadedObject($this->product)) {
|
||||
return false;
|
||||
}
|
||||
$productSettings = $this->getProductPresentationSettings();
|
||||
// Hook displayProductExtraContent
|
||||
$extraContentFinder = new ProductExtraContentFinder();
|
||||
|
||||
$product = $this->objectPresenter->present($this->product);
|
||||
$product['id_product'] = (int) $this->product->id;
|
||||
$product['out_of_stock'] = (int) $this->product->out_of_stock;
|
||||
$product['new'] = (int) $this->product->new;
|
||||
$product['id_product_attribute'] = (int) $id_product_attribute;
|
||||
$product['minimal_quantity'] = $this->getProductMinimalQuantity($product);
|
||||
$product['quantity_wanted'] = $this->getRequiredQuantity($product);
|
||||
$product['extraContent'] = $extraContentFinder->addParams(array('product' => $this->product))->present();
|
||||
|
||||
$product_full = Product::getProductProperties($this->context->language->id, $product, $this->context);
|
||||
|
||||
$product_full = $this->addProductCustomizationData($product_full);
|
||||
|
||||
$product_full['show_quantities'] = (bool) (
|
||||
Configuration::get('PS_DISPLAY_QTIES')
|
||||
&& Configuration::get('PS_STOCK_MANAGEMENT')
|
||||
&& $this->product->quantity > 0
|
||||
&& $this->product->available_for_order
|
||||
&& !Configuration::isCatalogMode()
|
||||
);
|
||||
$product_full['quantity_label'] = ($this->product->quantity > 1) ? $this->trans('Items', array(), 'Shop.Theme.Catalog') : $this->trans('Item', array(), 'Shop.Theme.Catalog');
|
||||
$product_full['quantity_discounts'] = $this->quantity_discounts;
|
||||
|
||||
if ($product_full['unit_price_ratio'] > 0) {
|
||||
$unitPrice = ($productSettings->include_taxes) ? $product_full['price'] : $product_full['price_tax_exc'];
|
||||
$product_full['unit_price'] = $unitPrice / $product_full['unit_price_ratio'];
|
||||
}
|
||||
|
||||
$group_reduction = GroupReduction::getValueForProduct($this->product->id, (int) Group::getCurrent()->id);
|
||||
if ($group_reduction === false) {
|
||||
$group_reduction = Group::getReduction((int) $this->context->cookie->id_customer) / 100;
|
||||
}
|
||||
$product_full['customer_group_discount'] = $group_reduction;
|
||||
$presenter = $this->getProductPresenter();
|
||||
|
||||
return $presenter->present(
|
||||
$productSettings,
|
||||
$product_full,
|
||||
$this->context->language
|
||||
);
|
||||
}
|
||||
|
||||
public function getTemplateVarProduct1($id_product)
|
||||
{
|
||||
if ($id_product) {
|
||||
$this->product = new Product($id_product, true, $this->context->language->id, $this->context->shop->id);
|
||||
}
|
||||
|
||||
if (!Validate::isLoadedObject($this->product)) {
|
||||
return false;
|
||||
}
|
||||
$productSettings = $this->getProductPresentationSettings();
|
||||
// Hook displayProductExtraContent
|
||||
$extraContentFinder = new ProductExtraContentFinder();
|
||||
|
||||
$product = $this->objectPresenter->present($this->product);
|
||||
$product['id_product'] = (int) $this->product->id;
|
||||
$product['out_of_stock'] = (int) $this->product->out_of_stock;
|
||||
$product['new'] = (int) $this->product->new;
|
||||
$product['id_product_attribute'] = Product::getDefaultAttribute((int)$id_product);
|
||||
$product['minimal_quantity'] = $this->getProductMinimalQuantity($product);
|
||||
$product['quantity_wanted'] = $this->getRequiredQuantity($product);
|
||||
$product['extraContent'] = $extraContentFinder->addParams(array('product' => $this->product))->present();
|
||||
|
||||
$product_full = Product::getProductProperties($this->context->language->id, $product, $this->context);
|
||||
$product_full = $this->addProductCustomizationData($product_full);
|
||||
|
||||
$product_full['show_quantities'] = (bool) (
|
||||
Configuration::get('PS_DISPLAY_QTIES')
|
||||
&& Configuration::get('PS_STOCK_MANAGEMENT')
|
||||
&& $this->product->quantity > 0
|
||||
&& $this->product->available_for_order
|
||||
&& !Configuration::isCatalogMode()
|
||||
);
|
||||
$product_full['quantity_label'] = ($this->product->quantity > 1) ? $this->trans('Items', array(), 'Shop.Theme.Catalog') : $this->trans('Item', array(), 'Shop.Theme.Catalog');
|
||||
$product_full['quantity_discounts'] = $this->quantity_discounts;
|
||||
|
||||
if ($product_full['unit_price_ratio'] > 0) {
|
||||
$unitPrice = ($productSettings->include_taxes) ? $product_full['price'] : $product_full['price_tax_exc'];
|
||||
$product_full['unit_price'] = $unitPrice / $product_full['unit_price_ratio'];
|
||||
}
|
||||
|
||||
$group_reduction = GroupReduction::getValueForProduct($this->product->id, (int) Group::getCurrent()->id);
|
||||
if ($group_reduction === false) {
|
||||
$group_reduction = Group::getReduction((int) $this->context->cookie->id_customer) / 100;
|
||||
}
|
||||
$product_full['customer_group_discount'] = $group_reduction;
|
||||
|
||||
if ((bool)Module::isEnabled('appagebuilder')) {
|
||||
$appagebuilder = Module::getInstanceByName('appagebuilder');
|
||||
$product_full['description'] = $appagebuilder->buildShortCode($product_full['description']);
|
||||
$product_full['description_short'] = $appagebuilder->buildShortCode($product_full['description_short']);
|
||||
}
|
||||
$presenter = $this->getProductPresenter();
|
||||
|
||||
return $presenter->present(
|
||||
$productSettings,
|
||||
$product_full,
|
||||
$this->context->language
|
||||
);
|
||||
}
|
||||
}
|
||||
438
modules/leofeature/classes/ProductReview.php
Normal file
438
modules/leofeature/classes/ProductReview.php
Normal file
@@ -0,0 +1,438 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Leotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Leo feature for prestashop 1.7: ajax cart, review, compare, wishlist at product list
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author leotheme <leotheme@gmail.com>
|
||||
* @copyright 2007-2015 Leotheme
|
||||
* @license http://leotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ProductReview extends ObjectModel
|
||||
{
|
||||
public $id;
|
||||
|
||||
/** @var integer Product's id */
|
||||
public $id_product;
|
||||
|
||||
/** @var integer Customer's id */
|
||||
public $id_customer;
|
||||
|
||||
/** @var integer Guest's id */
|
||||
public $id_guest;
|
||||
|
||||
/** @var integer Customer name */
|
||||
public $customer_name;
|
||||
|
||||
/** @var string Title */
|
||||
public $title;
|
||||
|
||||
/** @var string Content */
|
||||
public $content;
|
||||
|
||||
/** @var integer Grade */
|
||||
public $grade;
|
||||
|
||||
/** @var boolean Validate */
|
||||
public $validate = 0;
|
||||
|
||||
public $deleted = 0;
|
||||
|
||||
/** @var string Object creation date */
|
||||
public $date_add;
|
||||
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
*/
|
||||
public static $definition = array(
|
||||
'table' => 'leofeature_product_review',
|
||||
'primary' => 'id_product_review',
|
||||
'fields' => array(
|
||||
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'id_guest' => array('type' => self::TYPE_INT),
|
||||
'customer_name' => array('type' => self::TYPE_STRING),
|
||||
'title' => array('type' => self::TYPE_STRING),
|
||||
'content' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'size' => 65535, 'required' => true),
|
||||
'grade' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
|
||||
'validate' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'deleted' => array('type' => self::TYPE_BOOL),
|
||||
'date_add' => array('type' => self::TYPE_DATE),
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Get reviews by IdProduct
|
||||
*
|
||||
* @return array Reviews
|
||||
*/
|
||||
public static function getByProduct($id_product, $p = 1, $n = null, $id_customer = null)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_product)) {
|
||||
return false;
|
||||
}
|
||||
$validate = Configuration::get('LEOFEATURE_PRODUCT_REVIEWS_MODERATE');
|
||||
$p = (int)$p;
|
||||
$n = (int)$n;
|
||||
if ($p <= 1) {
|
||||
$p = 1;
|
||||
}
|
||||
if ($n != null && $n <= 0) {
|
||||
$n = 5;
|
||||
}
|
||||
|
||||
$cache_id = 'ProductReview::getByProduct_'.(int)$id_product.'-'.(int)$p.'-'.(int)$n.'-'.(int)$id_customer.'-'.(bool)$validate;
|
||||
if (!Cache::isStored($cache_id)) {
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT pc.`id_product_review`,
|
||||
(SELECT count(*) FROM `'._DB_PREFIX_.'leofeature_product_review_usefulness` pcu WHERE pcu.`id_product_review` = pc.`id_product_review` AND pcu.`usefulness` = 1) as total_useful,
|
||||
(SELECT count(*) FROM `'._DB_PREFIX_.'leofeature_product_review_usefulness` pcu WHERE pcu.`id_product_review` = pc.`id_product_review`) as total_advice, '.
|
||||
((int)$id_customer ? '(SELECT count(*) FROM `'._DB_PREFIX_.'leofeature_product_review_usefulness` pcuc WHERE pcuc.`id_product_review` = pc.`id_product_review` AND pcuc.id_customer = '.(int)$id_customer.') as customer_advice, ' : '').
|
||||
((int)$id_customer ? '(SELECT count(*) FROM `'._DB_PREFIX_.'leofeature_product_review_report` pcrc WHERE pcrc.`id_product_review` = pc.`id_product_review` AND pcrc.id_customer = '.(int)$id_customer.') as customer_report, ' : '').'
|
||||
if (c.id_customer, CONCAT(c.`firstname`, \' \', c.`lastname`), pc.customer_name) customer_name, pc.`content`, pc.`grade`, pc.`date_add`, pc.title
|
||||
FROM `'._DB_PREFIX_.'leofeature_product_review` pc
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON c.`id_customer` = pc.`id_customer`
|
||||
WHERE pc.`id_product` = '.(int)($id_product).($validate == '1' ? ' AND pc.`validate` = 1' : '').'
|
||||
ORDER BY pc.`date_add` DESC
|
||||
'.($n ? 'LIMIT '.(int)(($p - 1) * $n).', '.(int)($n) : ''));
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return customer's review
|
||||
*
|
||||
* @return arrayReviews
|
||||
*/
|
||||
public static function getByCustomer($id_product, $id_customer, $get_last = false, $id_guest = false)
|
||||
{
|
||||
$cache_id = 'ProductReview::getByCustomer_'.(int)$id_product.'-'.(int)$id_customer.'-'.(bool)$get_last.'-'.(int)$id_guest;
|
||||
if (!Cache::isStored($cache_id)) {
|
||||
$results = Db::getInstance()->executeS('SELECT *
|
||||
FROM `'._DB_PREFIX_.'leofeature_product_review` pc
|
||||
WHERE pc.`id_product` = '.(int)$id_product.'
|
||||
AND '.(!$id_guest ? 'pc.`id_customer` = '.(int)$id_customer : 'pc.`id_guest` = '.(int)$id_guest).'
|
||||
ORDER BY pc.`date_add` DESC '
|
||||
.($get_last ? 'LIMIT 1' : ''));
|
||||
|
||||
if ($get_last && count($results)) {
|
||||
$results = array_shift($results);
|
||||
}
|
||||
|
||||
Cache::store($cache_id, $results);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Grade By product
|
||||
*
|
||||
* @return array Grades
|
||||
*/
|
||||
public static function getGradeByProduct($id_product, $id_lang)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_product) || !Validate::isUnsignedId($id_lang)) {
|
||||
return false;
|
||||
}
|
||||
$validate = Configuration::get('LEOFEATURE_PRODUCT_REVIEWS_MODERATE');
|
||||
|
||||
return (Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT pc.`id_product_review`, pcg.`grade`, pccl.`name`, pcc.`id_product_review_criterion`
|
||||
FROM `'._DB_PREFIX_.'leofeature_product_review` pc
|
||||
LEFT JOIN `'._DB_PREFIX_.'leofeature_product_review_grade` pcg ON (pcg.`id_product_review` = pc.`id_product_review`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'leofeature_product_review_criterion` pcc ON (pcc.`id_product_review_criterion` = pcg.`id_product_review_criterion`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'leofeature_product_review_criterion_lang` pccl ON (pccl.`id_product_review_criterion` = pcg.`id_product_review_criterion`)
|
||||
WHERE pc.`id_product` = '.(int)$id_product.'
|
||||
AND pccl.`id_lang` = '.(int)$id_lang.($validate == '1' ? ' AND pc.`validate` = 1' : '')));
|
||||
}
|
||||
|
||||
public static function getRatings($id_product)
|
||||
{
|
||||
$validate = Configuration::get('LEOFEATURE_PRODUCT_REVIEWS_MODERATE');
|
||||
|
||||
$sql = 'SELECT (SUM(pc.`grade`) / COUNT(pc.`grade`)) AS avg,
|
||||
MIN(pc.`grade`) AS min,
|
||||
MAX(pc.`grade`) AS max
|
||||
FROM `'._DB_PREFIX_.'leofeature_product_review` pc
|
||||
WHERE pc.`id_product` = '.(int)$id_product.'
|
||||
AND pc.`deleted` = 0'.
|
||||
($validate == '1' ? ' AND pc.`validate` = 1' : '');
|
||||
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
||||
}
|
||||
|
||||
public static function getAverageGrade($id_product)
|
||||
{
|
||||
$validate = Configuration::get('LEOFEATURE_PRODUCT_REVIEWS_MODERATE');
|
||||
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT (SUM(pc.`grade`) / COUNT(pc.`grade`)) AS grade
|
||||
FROM `'._DB_PREFIX_.'leofeature_product_review` pc
|
||||
WHERE pc.`id_product` = '.(int)$id_product.'
|
||||
AND pc.`deleted` = 0'.
|
||||
($validate == '1' ? ' AND pc.`validate` = 1' : ''));
|
||||
}
|
||||
|
||||
public static function getAveragesByProduct($id_product, $id_lang)
|
||||
{
|
||||
/* Get all grades */
|
||||
$grades = ProductReview::getGradeByProduct((int)$id_product, (int)$id_lang);
|
||||
$total = ProductReview::getGradedReviewNumber((int)$id_product);
|
||||
if (!count($grades) || (!$total)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
/* Addition grades for each criterion */
|
||||
$criterionsGradeTotal = array();
|
||||
$count_grades = count($grades);
|
||||
for ($i = 0; $i < $count_grades; ++$i) {
|
||||
if (array_key_exists($grades[$i]['id_product_review_criterion'], $criterionsGradeTotal) === false) {
|
||||
$criterionsGradeTotal[$grades[$i]['id_product_review_criterion']] = (int)($grades[$i]['grade']);
|
||||
} else {
|
||||
$criterionsGradeTotal[$grades[$i]['id_product_review_criterion']] += (int)($grades[$i]['grade']);
|
||||
}
|
||||
}
|
||||
|
||||
/* Finally compute the averages */
|
||||
$averages = array();
|
||||
foreach ($criterionsGradeTotal as $key => $criterionGradeTotal) {
|
||||
$averages[(int)($key)] = (int)($total) ? ((int)($criterionGradeTotal) / (int)($total)) : 0;
|
||||
}
|
||||
return $averages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return number of reviews and average grade by products
|
||||
*
|
||||
* @return array Info
|
||||
*/
|
||||
public static function getReviewNumber($id_product)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_product)) {
|
||||
return false;
|
||||
}
|
||||
$validate = (int)Configuration::get('LEOFEATURE_PRODUCT_REVIEWS_MODERATE');
|
||||
$cache_id = 'ProductReview::getReviewNumber_'.(int)$id_product.'-'.$validate;
|
||||
if (!Cache::isStored($cache_id)) {
|
||||
$result = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT COUNT(`id_product_review`) AS "nbr"
|
||||
FROM `'._DB_PREFIX_.'leofeature_product_review` pc
|
||||
WHERE `id_product` = '.(int)($id_product).($validate == '1' ? ' AND `validate` = 1' : ''));
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return number of reviews and average grade by products
|
||||
*
|
||||
* @return array Info
|
||||
*/
|
||||
public static function getGradedReviewNumber($id_product)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_product)) {
|
||||
return false;
|
||||
}
|
||||
$validate = (int)Configuration::get('LEOFEATURE_PRODUCT_REVIEWS_MODERATE');
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT COUNT(pc.`id_product`) AS nbr
|
||||
FROM `'._DB_PREFIX_.'leofeature_product_review` pc
|
||||
WHERE `id_product` = '.(int)($id_product).($validate == '1' ? ' AND `validate` = 1' : '').'
|
||||
AND `grade` > 0');
|
||||
return (int)($result['nbr']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get reviews by Validation
|
||||
*
|
||||
* @return array Reviews
|
||||
*/
|
||||
public static function getByValidate($validate = '0', $deleted = false)
|
||||
{
|
||||
$sql = '
|
||||
SELECT pc.`id_product_review`, pc.`id_product`, if (c.id_customer, CONCAT(c.`firstname`, \' \', c.`lastname`), pc.customer_name) customer_name, pc.`title`, pc.`content`, pc.`grade`, pc.`date_add`, pl.`name`
|
||||
FROM `'._DB_PREFIX_.'leofeature_product_review` pc
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = pc.`id_customer`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = pc.`id_product` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Shop::addSqlRestrictionOnLang('pl').')
|
||||
WHERE pc.`validate` = '.(int)$validate;
|
||||
|
||||
$sql .= ' ORDER BY pc.`date_add` DESC';
|
||||
|
||||
// validate module
|
||||
unset($deleted);
|
||||
|
||||
return (Db::getInstance()->executeS($sql));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all reviews
|
||||
*
|
||||
* @return array Reviews
|
||||
*/
|
||||
public static function getAll()
|
||||
{
|
||||
return (Db::getInstance()->executeS('
|
||||
SELECT pc.`id_product_review`, pc.`id_product`, if (c.id_customer, CONCAT(c.`firstname`, \' \', c.`lastname`), pc.customer_name) customer_name, pc.`content`, pc.`grade`, pc.`date_add`, pl.`name`
|
||||
FROM `'._DB_PREFIX_.'leofeature_product_review` pc
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = pc.`id_customer`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = pc.`id_product` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Shop::addSqlRestrictionOnLang('pl').')
|
||||
ORDER BY pc.`date_add` DESC'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a comment
|
||||
*
|
||||
* @return boolean succeed
|
||||
*/
|
||||
public function validate($validate = '1')
|
||||
{
|
||||
if (!Validate::isUnsignedId($this->id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$success = (Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'leofeature_product_review` SET
|
||||
`validate` = '.(int)$validate.'
|
||||
WHERE `id_product_review` = '.(int)$this->id));
|
||||
|
||||
Hook::exec('actionObjectProductReviewValidateAfter', array('object' => $this));
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a comment, grade and report data
|
||||
*
|
||||
* @return boolean succeed
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
ProductReview::deleteGrades($this->id);
|
||||
ProductReview::deleteReports($this->id);
|
||||
ProductReview::deleteUsefulness($this->id);
|
||||
parent::delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Grades
|
||||
*
|
||||
* @return boolean succeed
|
||||
*/
|
||||
public static function deleteGrades($id_product_review)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_product_review)) {
|
||||
return false;
|
||||
}
|
||||
return (Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'leofeature_product_review_grade`
|
||||
WHERE `id_product_review` = '.(int)$id_product_review));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Reports
|
||||
*
|
||||
* @return boolean succeed
|
||||
*/
|
||||
public static function deleteReports($id_product_review)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_product_review)) {
|
||||
return false;
|
||||
}
|
||||
return (Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'leofeature_product_review_report`
|
||||
WHERE `id_product_review` = '.(int)$id_product_review));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete usefulness
|
||||
*
|
||||
* @return boolean succeed
|
||||
*/
|
||||
public static function deleteUsefulness($id_product_review)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_product_review)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'leofeature_product_review_usefulness`
|
||||
WHERE `id_product_review` = '.(int)$id_product_review));
|
||||
}
|
||||
|
||||
/**
|
||||
* Report comment
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function reportReview($id_product_review, $id_customer)
|
||||
{
|
||||
return (Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'leofeature_product_review_report` (`id_product_review`, `id_customer`)
|
||||
VALUES ('.(int)$id_product_review.', '.(int)$id_customer.')'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Comment already report
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isAlreadyReport($id_product_review, $id_customer)
|
||||
{
|
||||
return (bool)Db::getInstance()->getValue('SELECT COUNT(*)
|
||||
FROM `'._DB_PREFIX_.'leofeature_product_review_report`
|
||||
WHERE `id_customer` = '.(int)$id_customer.'
|
||||
AND `id_product_review` = '.(int)$id_product_review);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set comment usefulness
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function setReviewUsefulness($id_product_review, $usefulness, $id_customer)
|
||||
{
|
||||
return (Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'leofeature_product_review_usefulness` (`id_product_review`, `usefulness`, `id_customer`)
|
||||
VALUES ('.(int)$id_product_review.', '.(int)$usefulness.', '.(int)$id_customer.')'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Usefulness already set
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isAlreadyUsefulness($id_product_review, $id_customer)
|
||||
{
|
||||
return (bool)Db::getInstance()->getValue('SELECT COUNT(*)
|
||||
FROM `'._DB_PREFIX_.'leofeature_product_review_usefulness`
|
||||
WHERE `id_customer` = '.(int)$id_customer.'
|
||||
AND `id_product_review` = '.(int)$id_product_review);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get reported reviews
|
||||
*
|
||||
* @return array Reviews
|
||||
*/
|
||||
public static function getReportedReviews()
|
||||
{
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT DISTINCT(pc.`id_product_review`), pc.`id_product`, if (c.id_customer, CONCAT(c.`firstname`, \' \', c.`lastname`), pc.customer_name) customer_name, pc.`content`, pc.`grade`, pc.`date_add`, pl.`name`, pc.`title`
|
||||
FROM `'._DB_PREFIX_.'leofeature_product_review_report` pcr
|
||||
LEFT JOIN `'._DB_PREFIX_.'leofeature_product_review` pc
|
||||
ON pcr.id_product_review = pc.id_product_review
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = pc.`id_customer`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = pc.`id_product` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.' AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Shop::addSqlRestrictionOnLang('pl').')
|
||||
ORDER BY pc.`date_add` DESC');
|
||||
}
|
||||
}
|
||||
277
modules/leofeature/classes/ProductReviewCriterion.php
Normal file
277
modules/leofeature/classes/ProductReviewCriterion.php
Normal file
@@ -0,0 +1,277 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Leotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Leo feature for prestashop 1.7: ajax cart, review, compare, wishlist at product list
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author leotheme <leotheme@gmail.com>
|
||||
* @copyright 2007-2015 Leotheme
|
||||
* @license http://leotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
class ProductReviewCriterion extends ObjectModel
|
||||
{
|
||||
public $id;
|
||||
public $id_product_review_criterion_type;
|
||||
public $name;
|
||||
public $active = true;
|
||||
|
||||
const MODULE_NAME = 'leofeature';
|
||||
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
*/
|
||||
public static $definition = array(
|
||||
'table' => 'leofeature_product_review_criterion',
|
||||
'primary' => 'id_product_review_criterion',
|
||||
'multilang' => true,
|
||||
'fields' => array(
|
||||
'id_product_review_criterion_type' => array('type' => self::TYPE_INT),
|
||||
'active' => array('type' => self::TYPE_BOOL),
|
||||
// Lang fields
|
||||
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),
|
||||
)
|
||||
);
|
||||
|
||||
public function delete()
|
||||
{
|
||||
if (!parent::delete()) {
|
||||
return false;
|
||||
}
|
||||
if ($this->id_product_review_criterion_type == 2) {
|
||||
if (!Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'leofeature_product_review_criterion_category WHERE id_product_review_criterion='.(int)$this->id)) {
|
||||
return false;
|
||||
}
|
||||
} elseif ($this->id_product_review_criterion_type == 3) {
|
||||
if (!Db::getInstance()->execute('
|
||||
DELETE FROM '._DB_PREFIX_.'leofeature_product_review_criterion_product
|
||||
WHERE id_product_review_criterion='.(int)$this->id)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'leofeature_product_review_grade`
|
||||
WHERE `id_product_review_criterion` = '.(int)$this->id);
|
||||
}
|
||||
|
||||
public function update($nullValues = false)
|
||||
{
|
||||
// print_r('kkk');die();
|
||||
$previousUpdate = new self((int)$this->id);
|
||||
if (!parent::update($nullValues)) {
|
||||
return false;
|
||||
}
|
||||
if ($previousUpdate->id_product_review_criterion_type != $this->id_product_review_criterion_type) {
|
||||
if ($previousUpdate->id_product_review_criterion_type == 2) {
|
||||
return Db::getInstance()->execute('
|
||||
DELETE FROM '._DB_PREFIX_.'leofeature_product_review_criterion_category
|
||||
WHERE id_product_review_criterion = '.(int)$previousUpdate->id);
|
||||
} elseif ($previousUpdate->id_product_review_criterion_type == 3) {
|
||||
return Db::getInstance()->execute('
|
||||
DELETE FROM '._DB_PREFIX_.'leofeature_product_review_criterion_product
|
||||
WHERE id_product_review_criterion = '.(int)$previousUpdate->id);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Link a review Criterion to a product
|
||||
*
|
||||
* @return boolean succeed
|
||||
*/
|
||||
public function addProduct($id_product)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_product)) {
|
||||
die(Tools::displayError());
|
||||
}
|
||||
return Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'leofeature_product_review_criterion_product` (`id_product_review_criterion`, `id_product`)
|
||||
VALUES('.(int)$this->id.','.(int)$id_product.')
|
||||
');
|
||||
}
|
||||
|
||||
/**
|
||||
* Link a review Criterion to a category
|
||||
*
|
||||
* @return boolean succeed
|
||||
*/
|
||||
public function addCategory($id_category)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_category)) {
|
||||
die(Tools::displayError());
|
||||
}
|
||||
return Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'leofeature_product_review_criterion_category` (`id_product_review_criterion`, `id_category`)
|
||||
VALUES('.(int)$this->id.','.(int)$id_category.')');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add grade to a criterion
|
||||
*
|
||||
* @return boolean succeed
|
||||
*/
|
||||
public function addGrade($id_product_review, $grade)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_product_review)) {
|
||||
die(Tools::displayError());
|
||||
}
|
||||
if ($grade < 0) {
|
||||
$grade = 0;
|
||||
} elseif ($grade > 10) {
|
||||
$grade = 10;
|
||||
}
|
||||
return (Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'leofeature_product_review_grade`
|
||||
(`id_product_review`, `id_product_review_criterion`, `grade`) VALUES(
|
||||
'.(int)($id_product_review).',
|
||||
'.(int)$this->id.',
|
||||
'.(int)($grade).')'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get criterion by Product
|
||||
*
|
||||
* @return array Criterion
|
||||
*/
|
||||
public static function getByProduct($id_product, $id_lang)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_product) || !Validate::isUnsignedId($id_lang)) {
|
||||
die(Tools::displayError());
|
||||
}
|
||||
$alias = 'p';
|
||||
$table = '';
|
||||
// check if version > 1.5 to add shop association
|
||||
if (version_compare(_PS_VERSION_, '1.5', '>')) {
|
||||
$table = '_shop';
|
||||
$alias = 'ps';
|
||||
}
|
||||
|
||||
$cache_id = 'ProductReviewCriterion::getByProduct_'.(int)$id_product.'-'.(int)$id_lang;
|
||||
if (!Cache::isStored($cache_id)) {
|
||||
$result = Db::getInstance()->executeS('
|
||||
SELECT pcc.`id_product_review_criterion`, pccl.`name`
|
||||
FROM `'._DB_PREFIX_.'leofeature_product_review_criterion` pcc
|
||||
LEFT JOIN `'._DB_PREFIX_.'leofeature_product_review_criterion_lang` pccl
|
||||
ON (pcc.id_product_review_criterion = pccl.id_product_review_criterion)
|
||||
LEFT JOIN `'._DB_PREFIX_.'leofeature_product_review_criterion_product` pccp
|
||||
ON (pcc.`id_product_review_criterion` = pccp.`id_product_review_criterion` AND pccp.`id_product` = '.(int)$id_product.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'leofeature_product_review_criterion_category` pccc
|
||||
ON (pcc.`id_product_review_criterion` = pccc.`id_product_review_criterion`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product'.$table.'` '.$alias.'
|
||||
ON ('.$alias.'.id_category_default = pccc.id_category AND '.$alias.'.id_product = '.(int)$id_product.')
|
||||
WHERE pccl.`id_lang` = '.(int)($id_lang).'
|
||||
AND (
|
||||
pccp.id_product IS NOT NULL
|
||||
OR ps.id_product IS NOT NULL
|
||||
OR pcc.id_product_review_criterion_type = 1
|
||||
)
|
||||
AND pcc.active = 1
|
||||
GROUP BY pcc.id_product_review_criterion
|
||||
');
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Criterions
|
||||
*
|
||||
* @return array Criterions
|
||||
*/
|
||||
public static function getCriterions($id_lang, $type = false, $active = false)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_lang)) {
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
$sql = '
|
||||
SELECT pcc.`id_product_review_criterion`, pcc.id_product_review_criterion_type, pccl.`name`, pcc.active
|
||||
FROM `'._DB_PREFIX_.'leofeature_product_review_criterion` pcc
|
||||
JOIN `'._DB_PREFIX_.'leofeature_product_review_criterion_lang` pccl ON (pcc.id_product_review_criterion = pccl.id_product_review_criterion)
|
||||
WHERE pccl.`id_lang` = '.(int)$id_lang.($active ? ' AND active = 1' : '').($type ? ' AND id_product_review_criterion_type = '.(int)$type : '').'
|
||||
ORDER BY pccl.`name` ASC';
|
||||
$criterions = Db::getInstance()->executeS($sql);
|
||||
|
||||
$types = self::getTypes();
|
||||
foreach ($criterions as $key => $data) {
|
||||
$criterions[$key]['type_name'] = $types[$data['id_product_review_criterion_type']];
|
||||
}
|
||||
|
||||
return $criterions;
|
||||
}
|
||||
|
||||
public function getProducts()
|
||||
{
|
||||
$res = Db::getInstance()->executeS('
|
||||
SELECT pccp.id_product, pccp.id_product_review_criterion
|
||||
FROM `'._DB_PREFIX_.'leofeature_product_review_criterion_product` pccp
|
||||
WHERE pccp.id_product_review_criterion = '.(int)$this->id);
|
||||
$products = array();
|
||||
if ($res) {
|
||||
foreach ($res as $row) {
|
||||
$products[] = (int)$row['id_product'];
|
||||
}
|
||||
}
|
||||
return $products;
|
||||
}
|
||||
|
||||
public function getCategories()
|
||||
{
|
||||
$res = Db::getInstance()->executeS('
|
||||
SELECT pccc.id_category, pccc.id_product_review_criterion
|
||||
FROM `'._DB_PREFIX_.'leofeature_product_review_criterion_category` pccc
|
||||
WHERE pccc.id_product_review_criterion = '.(int)$this->id);
|
||||
$criterions = array();
|
||||
if ($res) {
|
||||
foreach ($res as $row) {
|
||||
$criterions[] = (int)$row['id_category'];
|
||||
}
|
||||
}
|
||||
return $criterions;
|
||||
}
|
||||
|
||||
public function deleteCategories()
|
||||
{
|
||||
return Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'leofeature_product_review_criterion_category`
|
||||
WHERE `id_product_review_criterion` = '.(int)$this->id);
|
||||
}
|
||||
|
||||
public function deleteProducts()
|
||||
{
|
||||
return Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'leofeature_product_review_criterion_product`
|
||||
WHERE `id_product_review_criterion` = '.(int)$this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get translation for a given module text
|
||||
*
|
||||
* Note: $specific parameter is mandatory for library files.
|
||||
* Otherwise, translation key will not match for Module library
|
||||
* when module is loaded with eval() Module::getModulesOnDisk()
|
||||
*
|
||||
* @param string $string String to translate
|
||||
* @param boolean|string $specific filename to use in translation key
|
||||
* @return string Translation
|
||||
*/
|
||||
public static function l($string, $specific = false)
|
||||
{
|
||||
return Translate::getModuleTranslation(self::MODULE_NAME, $string, ($specific) ? $specific : self::MODULE_NAME);
|
||||
}
|
||||
|
||||
public static function getTypes()
|
||||
{
|
||||
return array(
|
||||
1 => self::l('Valid for the entire catalog'),
|
||||
2 => self::l('Restricted to some categories'),
|
||||
3 => self::l('Restricted to some products')
|
||||
);
|
||||
}
|
||||
}
|
||||
43
modules/leofeature/classes/ProductReviewGrade.php
Normal file
43
modules/leofeature/classes/ProductReviewGrade.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Leotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Leo feature for prestashop 1.7: ajax cart, review, compare, wishlist at product list
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author leotheme <leotheme@gmail.com>
|
||||
* @copyright 2007-2015 Leotheme
|
||||
* @license http://leotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class ProductReviewGrade extends ObjectModel
|
||||
{
|
||||
public $id;
|
||||
|
||||
public $id_product_review;
|
||||
|
||||
public $id_product_review_criterion;
|
||||
|
||||
public $grade;
|
||||
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
*/
|
||||
public static $definition = array(
|
||||
'table' => 'leofeature_product_review_grade',
|
||||
'primary' => 'id_product_review_grade',
|
||||
'fields' => array(
|
||||
'id_product_review' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'id_product_review_criterion' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'grade' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
|
||||
)
|
||||
);
|
||||
}
|
||||
566
modules/leofeature/classes/WishList.php
Normal file
566
modules/leofeature/classes/WishList.php
Normal file
@@ -0,0 +1,566 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2015 Leotheme
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Leo feature for prestashop 1.7: ajax cart, review, compare, wishlist at product list
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* @author leotheme <leotheme@gmail.com>
|
||||
* @copyright 2007-2015 Leotheme
|
||||
* @license http://leotheme.com - prestashop template provider
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
# module validation
|
||||
exit;
|
||||
}
|
||||
|
||||
class WishList extends ObjectModel
|
||||
{
|
||||
/** @var integer Wishlist ID */
|
||||
public $id;
|
||||
|
||||
/** @var integer Customer ID */
|
||||
public $id_customer;
|
||||
|
||||
/** @var integer Token */
|
||||
public $token;
|
||||
|
||||
/** @var integer Name */
|
||||
public $name;
|
||||
|
||||
/** @var string Object creation date */
|
||||
public $date_add;
|
||||
|
||||
/** @var string Object last modification date */
|
||||
public $date_upd;
|
||||
|
||||
/** @var string Object last modification date */
|
||||
public $id_shop;
|
||||
|
||||
/** @var string Object last modification date */
|
||||
public $id_shop_group;
|
||||
|
||||
/** @var integer default */
|
||||
public $default;
|
||||
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
*/
|
||||
public static $definition = array(
|
||||
'table' => 'leofeature_wishlist',
|
||||
'primary' => 'id_wishlist',
|
||||
'fields' => array(
|
||||
'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'token' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'required' => true),
|
||||
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'required' => true),
|
||||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'id_shop_group' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'default' => array('type' => self::TYPE_BOOL, 'validate' => 'isUnsignedId'),
|
||||
)
|
||||
);
|
||||
|
||||
public function delete()
|
||||
{
|
||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'leofeature_wishlist_product` WHERE `id_wishlist` = '.(int)($this->id));
|
||||
if ($this->default) {
|
||||
$result = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'leofeature_wishlist` WHERE `id_customer` = '.(int)$this->id_customer.' and `id_wishlist` != '.(int)$this->id.' LIMIT 1');
|
||||
foreach ($result as $res) {
|
||||
Db::getInstance()->update('wishlist', array('default' => '1'), 'id_wishlist = '.(int)$res['id_wishlist']);
|
||||
}
|
||||
}
|
||||
if (isset($this->context->cookie->id_wishlist)) {
|
||||
unset($this->context->cookie->id_wishlist);
|
||||
}
|
||||
|
||||
return (parent::delete());
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment counter
|
||||
*
|
||||
* @return boolean succeed
|
||||
*/
|
||||
public static function incCounter($id_wishlist)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_wishlist)) {
|
||||
die(Tools::displayError());
|
||||
}
|
||||
$result = Db::getInstance()->getRow('
|
||||
SELECT `counter`
|
||||
FROM `'._DB_PREFIX_.'leofeature_wishlist`
|
||||
WHERE `id_wishlist` = '.(int)$id_wishlist);
|
||||
|
||||
if ($result == false || !count($result) || empty($result) === true) {
|
||||
return (false);
|
||||
}
|
||||
|
||||
return Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'leofeature_wishlist` SET
|
||||
`counter` = '.(int)($result['counter'] + 1).'
|
||||
WHERE `id_wishlist` = '.(int)$id_wishlist);
|
||||
}
|
||||
|
||||
public static function isExistsByNameForUser($name)
|
||||
{
|
||||
if (Shop::getContextShopID()) {
|
||||
$shop_restriction = 'AND id_shop = '.(int)Shop::getContextShopID();
|
||||
} elseif (Shop::getContextShopGroupID()) {
|
||||
$shop_restriction = 'AND id_shop_group = '.(int)Shop::getContextShopGroupID();
|
||||
} else {
|
||||
$shop_restriction = '';
|
||||
}
|
||||
|
||||
$context = Context::getContext();
|
||||
return Db::getInstance()->getValue('SELECT COUNT(*) AS total
|
||||
FROM `'._DB_PREFIX_.'leofeature_wishlist`
|
||||
WHERE `name` = \''.pSQL($name).'\'
|
||||
AND `id_customer` = '.(int)$context->customer->id.'
|
||||
'.$shop_restriction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if wishlist exists else false
|
||||
*
|
||||
* @return boolean exists
|
||||
*/
|
||||
public static function exists($id_wishlist, $id_customer, $return = false)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_wishlist) or !Validate::isUnsignedId($id_customer)) {
|
||||
die(Tools::displayError());
|
||||
}
|
||||
$result = Db::getInstance()->getRow('
|
||||
SELECT `id_wishlist`, `name`, `token`
|
||||
FROM `'._DB_PREFIX_.'leofeature_wishlist`
|
||||
WHERE `id_wishlist` = '.(int)($id_wishlist).'
|
||||
AND `id_customer` = '.(int)($id_customer).'
|
||||
AND `id_shop` = '.(int)Context::getContext()->shop->id);
|
||||
if (empty($result) === false and $result != false and sizeof($result)) {
|
||||
if ($return === false) {
|
||||
return (true);
|
||||
} else {
|
||||
return ($result);
|
||||
}
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Customers having a wishlist
|
||||
*
|
||||
* @return array Results
|
||||
*/
|
||||
public static function getCustomers()
|
||||
{
|
||||
$cache_id = 'WhishList::getCustomers';
|
||||
if (!Cache::isStored($cache_id)) {
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT c.`id_customer`, c.`firstname`, c.`lastname`
|
||||
FROM `'._DB_PREFIX_.'leofeature_wishlist` w
|
||||
INNER JOIN `'._DB_PREFIX_.'customer` c ON c.`id_customer` = w.`id_customer`
|
||||
ORDER BY c.`firstname` ASC');
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ID wishlist by Token
|
||||
*
|
||||
* @return array Results
|
||||
*/
|
||||
public static function getByToken($token)
|
||||
{
|
||||
if (!Validate::isMessage($token)) {
|
||||
die(Tools::displayError());
|
||||
}
|
||||
return (Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT w.`id_wishlist`, w.`name`, w.`id_customer`, c.`firstname`, c.`lastname`
|
||||
FROM `'._DB_PREFIX_.'leofeature_wishlist` w
|
||||
INNER JOIN `'._DB_PREFIX_.'customer` c ON c.`id_customer` = w.`id_customer`
|
||||
WHERE `token` = \''.pSQL($token).'\''));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Wishlists by Customer ID
|
||||
*
|
||||
* @return array Results
|
||||
*/
|
||||
public static function getByIdCustomer($id_customer)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_customer)) {
|
||||
die(Tools::displayError());
|
||||
}
|
||||
if (Shop::getContextShopID()) {
|
||||
$shop_restriction = 'AND id_shop = '.(int)Shop::getContextShopID();
|
||||
} elseif (Shop::getContextShopGroupID()) {
|
||||
$shop_restriction = 'AND id_shop_group = '.(int)Shop::getContextShopGroupID();
|
||||
} else {
|
||||
$shop_restriction = '';
|
||||
}
|
||||
|
||||
$cache_id = 'WhishList::getByIdCustomer_'.(int)$id_customer.'-'.(int)Shop::getContextShopID().'-'.(int)Shop::getContextShopGroupID();
|
||||
if (!Cache::isStored($cache_id)) {
|
||||
$result = Db::getInstance()->executeS('
|
||||
SELECT w.`id_wishlist`, w.`name`, w.`token`, w.`date_add`, w.`date_upd`, w.`counter`, w.`default`
|
||||
FROM `'._DB_PREFIX_.'leofeature_wishlist` w
|
||||
WHERE `id_customer` = '.(int)($id_customer).'
|
||||
'.$shop_restriction.'
|
||||
ORDER BY w.`name` ASC');
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
}
|
||||
|
||||
// public static function refreshWishList($id_wishlist)
|
||||
// {
|
||||
// $old_carts = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
// SELECT wp.id_product, wp.id_product_attribute, wpc.id_cart, UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(wpc.date_add) AS timecart
|
||||
// FROM `'._DB_PREFIX_.'wishlist_product_cart` wpc
|
||||
// JOIN `'._DB_PREFIX_.'leofeature_wishlist_product` wp ON (wp.id_wishlist_product = wpc.id_wishlist_product)
|
||||
// JOIN `'._DB_PREFIX_.'cart` c ON (c.id_cart = wpc.id_cart)
|
||||
// JOIN `'._DB_PREFIX_.'cart_product` cp ON (wpc.id_cart = cp.id_cart)
|
||||
// LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.id_cart = c.id_cart)
|
||||
// WHERE (wp.id_wishlist='.(int)($id_wishlist).' and o.id_cart IS NULL)
|
||||
// HAVING timecart >= 3600*6');
|
||||
|
||||
// if (isset($old_carts) AND $old_carts != false)
|
||||
// foreach ($old_carts AS $old_cart)
|
||||
// Db::getInstance()->execute('
|
||||
// DELETE FROM `'._DB_PREFIX_.'cart_product`
|
||||
// WHERE id_cart='.(int)($old_cart['id_cart']).' AND id_product='.(int)($old_cart['id_product']).' AND id_product_attribute='.(int)($old_cart['id_product_attribute'])
|
||||
// );
|
||||
|
||||
// $freshwish = Db::getInstance()->executeS('
|
||||
// SELECT wpc.id_cart, wpc.id_wishlist_product
|
||||
// FROM `'._DB_PREFIX_.'wishlist_product_cart` wpc
|
||||
// JOIN `'._DB_PREFIX_.'leofeature_wishlist_product` wp ON (wpc.id_wishlist_product = wp.id_wishlist_product)
|
||||
// JOIN `'._DB_PREFIX_.'cart` c ON (c.id_cart = wpc.id_cart)
|
||||
// LEFT JOIN `'._DB_PREFIX_.'cart_product` cp ON (cp.id_cart = wpc.id_cart AND cp.id_product = wp.id_product AND cp.id_product_attribute = wp.id_product_attribute)
|
||||
// WHERE (wp.id_wishlist = '.(int)($id_wishlist).' AND ((cp.id_product IS NULL AND cp.id_product_attribute IS NULL)))
|
||||
// ');
|
||||
// $res = Db::getInstance()->executeS('
|
||||
// SELECT wp.id_wishlist_product, cp.quantity AS cart_quantity, wpc.quantity AS wish_quantity, wpc.id_cart
|
||||
// FROM `'._DB_PREFIX_.'wishlist_product_cart` wpc
|
||||
// JOIN `'._DB_PREFIX_.'leofeature_wishlist_product` wp ON (wp.id_wishlist_product = wpc.id_wishlist_product)
|
||||
// JOIN `'._DB_PREFIX_.'cart` c ON (c.id_cart = wpc.id_cart)
|
||||
// JOIN `'._DB_PREFIX_.'cart_product` cp ON (cp.id_cart = wpc.id_cart AND cp.id_product = wp.id_product AND cp.id_product_attribute = wp.id_product_attribute)
|
||||
// WHERE wp.id_wishlist='.(int)($id_wishlist)
|
||||
// );
|
||||
|
||||
// if (isset($res) AND $res != false)
|
||||
// foreach ($res AS $refresh)
|
||||
// if ($refresh['wish_quantity'] > $refresh['cart_quantity'])
|
||||
// {
|
||||
// Db::getInstance()->execute('
|
||||
// UPDATE `'._DB_PREFIX_.'leofeature_wishlist_product`
|
||||
// SET `quantity`= `quantity` + '.((int)($refresh['wish_quantity']) - (int)($refresh['cart_quantity'])).'
|
||||
// WHERE id_wishlist_product='.(int)($refresh['id_wishlist_product'])
|
||||
// );
|
||||
// Db::getInstance()->execute('
|
||||
// UPDATE `'._DB_PREFIX_.'wishlist_product_cart`
|
||||
// SET `quantity`='.(int)($refresh['cart_quantity']).'
|
||||
// WHERE id_wishlist_product='.(int)($refresh['id_wishlist_product']).' AND id_cart='.(int)($refresh['id_cart'])
|
||||
// );
|
||||
// }
|
||||
// if (isset($freshwish) AND $freshwish != false)
|
||||
// foreach ($freshwish AS $prodcustomer)
|
||||
// {
|
||||
// Db::getInstance()->execute('
|
||||
// UPDATE `'._DB_PREFIX_.'leofeature_wishlist_product` SET `quantity`=`quantity` +
|
||||
// (
|
||||
// SELECT `quantity` FROM `'._DB_PREFIX_.'wishlist_product_cart`
|
||||
// WHERE `id_wishlist_product`='.(int)($prodcustomer['id_wishlist_product']).' AND `id_cart`='.(int)($prodcustomer['id_cart']).'
|
||||
// )
|
||||
// WHERE `id_wishlist_product`='.(int)($prodcustomer['id_wishlist_product']).' AND `id_wishlist`='.(int)($id_wishlist)
|
||||
// );
|
||||
// Db::getInstance()->execute('
|
||||
// DELETE FROM `'._DB_PREFIX_.'wishlist_product_cart`
|
||||
// WHERE `id_wishlist_product`='.(int)($prodcustomer['id_wishlist_product']).' AND `id_cart`='.(int)($prodcustomer['id_cart'])
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Get Wishlist products by Customer ID
|
||||
*
|
||||
* @return array Results
|
||||
*/
|
||||
public static function getProductByIdCustomer($id_wishlist, $id_customer, $id_lang, $id_product = null, $quantity = false)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_customer) or !Validate::isUnsignedId($id_lang) or !Validate::isUnsignedId($id_wishlist)) {
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
$products = Db::getInstance()->executeS('
|
||||
SELECT wp.`id_product`, wp.`quantity`, p.`quantity` AS product_quantity, pl.`name`, wp.`id_product_attribute`, wp.`priority`, pl.link_rewrite, cl.link_rewrite AS category_rewrite
|
||||
FROM `'._DB_PREFIX_.'leofeature_wishlist_product` wp
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = wp.`id_product`
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON pl.`id_product` = wp.`id_product`'.Shop::addSqlRestrictionOnLang('pl').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'leofeature_wishlist` w ON w.`id_wishlist` = wp.`id_wishlist`
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON cl.`id_category` = product_shop.`id_category_default` and cl.id_lang='.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').'
|
||||
WHERE w.`id_customer` = '.(int)($id_customer).'
|
||||
AND pl.`id_lang` = '.(int)($id_lang).'
|
||||
AND wp.`id_wishlist` = '.(int)($id_wishlist).
|
||||
(empty($id_product) === false ? ' AND wp.`id_product` = '.(int)($id_product) : '').
|
||||
($quantity == true ? ' AND wp.`quantity` != 0': '').'
|
||||
GROUP BY p.id_product, wp.id_product_attribute');
|
||||
|
||||
if (empty($products) === true or !sizeof($products)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
for ($i = 0; $i < sizeof($products); ++$i) {
|
||||
if (isset($products[$i]['id_product_attribute']) and Validate::isUnsignedInt($products[$i]['id_product_attribute'])) {
|
||||
$result = Db::getInstance()->executeS('
|
||||
SELECT al.`name` AS attribute_name, pa.`quantity` AS "attribute_quantity"
|
||||
FROM `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute` a ON (a.`id_attribute` = pac.`id_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON (ag.`id_attribute_group` = a.`id_attribute_group`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)($id_lang).')
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (ag.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)($id_lang).')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
|
||||
'.Shop::addSqlAssociation('product_attribute', 'pa').'
|
||||
WHERE pac.`id_product_attribute` = '.(int)($products[$i]['id_product_attribute']));
|
||||
|
||||
$products[$i]['attributes_small'] = '';
|
||||
|
||||
if ($result) {
|
||||
foreach ($result as $k => $row) {
|
||||
$products[$i]['attributes_small'] .= $row['attribute_name'].', ';
|
||||
}
|
||||
// validate module
|
||||
unset($k);
|
||||
}
|
||||
|
||||
$products[$i]['attributes_small'] = rtrim($products[$i]['attributes_small'], ', ');
|
||||
|
||||
if (isset($result[0])) {
|
||||
$products[$i]['attribute_quantity'] = $result[0]['attribute_quantity'];
|
||||
}
|
||||
} else {
|
||||
$products[$i]['attribute_quantity'] = $products[$i]['product_quantity'];
|
||||
}
|
||||
}
|
||||
return ($products);
|
||||
}
|
||||
|
||||
//DONGND:: get simple list product by wishlist
|
||||
public static function getSimpleProductByIdCustomer($id_customer, $id_shop)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_customer) or !Validate::isUnsignedId($id_shop)) {
|
||||
die(Tools::displayError());
|
||||
}
|
||||
$wishlists = Db::getInstance()->executeS('
|
||||
SELECT w.`id_wishlist`
|
||||
FROM `'._DB_PREFIX_.'leofeature_wishlist` w
|
||||
WHERE w.`id_customer` = '.(int)($id_customer).' AND w.`id_shop` = '.(int) $id_shop.'');
|
||||
|
||||
if (empty($wishlists) === true or !sizeof($wishlists)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$wishlist_product = array();
|
||||
foreach ($wishlists as $wishlists_val) {
|
||||
$product = Db::getInstance()->executeS('
|
||||
SELECT wp.`id_product`, wp.`id_product_attribute`
|
||||
FROM `'._DB_PREFIX_.'leofeature_wishlist_product` wp
|
||||
WHERE wp.`id_wishlist` = '.(int)$wishlists_val['id_wishlist'].'');
|
||||
$wishlist_product[$wishlists_val['id_wishlist']] = $product;
|
||||
}
|
||||
|
||||
return ($wishlist_product);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Wishlists number products by Customer ID
|
||||
*
|
||||
* @return array Results
|
||||
*/
|
||||
public static function getInfosByIdCustomer($id_customer, $id_wishlist)
|
||||
{
|
||||
if (Shop::getContextShopID()) {
|
||||
$shop_restriction = 'AND id_shop = '.(int)Shop::getContextShopID();
|
||||
} elseif (Shop::getContextShopGroupID()) {
|
||||
$shop_restriction = 'AND id_shop_group = '.(int)Shop::getContextShopGroupID();
|
||||
} else {
|
||||
$shop_restriction = '';
|
||||
}
|
||||
|
||||
if (!Validate::isUnsignedId($id_customer)) {
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
return (Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT SUM(wp.`quantity`) AS nbProducts, wp.`id_wishlist`
|
||||
FROM `'._DB_PREFIX_.'leofeature_wishlist_product` wp
|
||||
INNER JOIN `'._DB_PREFIX_.'leofeature_wishlist` w ON (w.`id_wishlist` = wp.`id_wishlist`)
|
||||
WHERE w.`id_customer` = '.(int)($id_customer).' AND wp.`id_wishlist` = '.(int)($id_wishlist).'
|
||||
'.$shop_restriction.'
|
||||
GROUP BY w.`id_wishlist`
|
||||
ORDER BY w.`name` ASC'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add product to ID wishlist
|
||||
*
|
||||
* @return boolean succeed
|
||||
*/
|
||||
public static function addProduct($id_wishlist, $id_customer, $id_product, $id_product_attribute, $quantity)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_wishlist) or !Validate::isUnsignedId($id_customer) or !Validate::isUnsignedId($id_product) or !Validate::isUnsignedId($quantity)) {
|
||||
die(Tools::displayError());
|
||||
}
|
||||
$result = Db::getInstance()->getRow('
|
||||
SELECT wp.`quantity`
|
||||
FROM `'._DB_PREFIX_.'leofeature_wishlist_product` wp
|
||||
JOIN `'._DB_PREFIX_.'leofeature_wishlist` w ON (w.`id_wishlist` = wp.`id_wishlist`)
|
||||
WHERE wp.`id_wishlist` = '.(int)($id_wishlist).'
|
||||
AND w.`id_customer` = '.(int)($id_customer).'
|
||||
AND wp.`id_product` = '.(int)($id_product).'
|
||||
AND wp.`id_product_attribute` = '.(int)($id_product_attribute));
|
||||
if (empty($result) === false and sizeof($result)) {
|
||||
if (($result['quantity'] + $quantity) <= 0) {
|
||||
return (WishList::removeProduct($id_wishlist, $id_customer, $id_product, $id_product_attribute));
|
||||
} else {
|
||||
return (Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'leofeature_wishlist_product` SET
|
||||
`quantity` = '.(int)($quantity + $result['quantity']).'
|
||||
WHERE `id_wishlist` = '.(int)($id_wishlist).'
|
||||
AND `id_product` = '.(int)($id_product).'
|
||||
AND `id_product_attribute` = '.(int)($id_product_attribute)));
|
||||
}
|
||||
} else {
|
||||
return (Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'leofeature_wishlist_product` (`id_wishlist`, `id_product`, `id_product_attribute`, `quantity`, `priority`) VALUES(
|
||||
'.(int)($id_wishlist).',
|
||||
'.(int)($id_product).',
|
||||
'.(int)($id_product_attribute).',
|
||||
'.(int)($quantity).', 1)'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update product to wishlist
|
||||
*
|
||||
* @return boolean succeed
|
||||
*/
|
||||
public static function updateProduct($id_wishlist, $id_product, $id_product_attribute, $priority, $quantity)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_wishlist) or !Validate::isUnsignedId($id_product) or !Validate::isUnsignedId($quantity) or $priority < 0 or $priority > 2) {
|
||||
die(Tools::displayError());
|
||||
}
|
||||
return (Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'leofeature_wishlist_product` SET
|
||||
`priority` = '.(int)($priority).',
|
||||
`quantity` = '.(int)($quantity).'
|
||||
WHERE `id_wishlist` = '.(int)($id_wishlist).'
|
||||
AND `id_product` = '.(int)($id_product).'
|
||||
AND `id_product_attribute` = '.(int)($id_product_attribute)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove product from wishlist
|
||||
*
|
||||
* @return boolean succeed
|
||||
*/
|
||||
public static function removeProduct($id_wishlist, $id_customer, $id_product, $id_product_attribute)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_wishlist) or !Validate::isUnsignedId($id_customer) or !Validate::isUnsignedId($id_product)) {
|
||||
die(Tools::displayError());
|
||||
}
|
||||
$result = Db::getInstance()->getRow('
|
||||
SELECT w.`id_wishlist`, wp.`id_wishlist_product`
|
||||
FROM `'._DB_PREFIX_.'leofeature_wishlist` w
|
||||
LEFT JOIN `'._DB_PREFIX_.'leofeature_wishlist_product` wp ON (wp.`id_wishlist` = w.`id_wishlist`)
|
||||
WHERE `id_customer` = '.(int)($id_customer).'
|
||||
AND w.`id_wishlist` = '.(int)($id_wishlist));
|
||||
|
||||
if (empty($result) === true or $result === false or !sizeof($result) or $result['id_wishlist'] != $id_wishlist) {
|
||||
return (false);
|
||||
}
|
||||
|
||||
return Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'leofeature_wishlist_product`
|
||||
WHERE `id_wishlist` = '.(int)($id_wishlist).'
|
||||
AND `id_product` = '.(int)($id_product).'
|
||||
AND `id_product_attribute` = '.(int)($id_product_attribute));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return if there is a default already set
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isDefault($id_customer)
|
||||
{
|
||||
return (Bool)Db::getInstance()->getValue('SELECT * FROM `'._DB_PREFIX_.'leofeature_wishlist` WHERE `id_customer` = '.(int)$id_customer.' AND `default` = 1');
|
||||
}
|
||||
|
||||
public static function getDefault($id_customer)
|
||||
{
|
||||
return Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'leofeature_wishlist` WHERE `id_customer` = '.(int)$id_customer.' AND `default` = 1');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set current WishList as default
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setDefault()
|
||||
{
|
||||
if ($default = $this->getDefault($this->id_customer)) {
|
||||
Db::getInstance()->update('leofeature_wishlist', array('default' => '0'), 'id_wishlist = '.(int)$default[0]['id_wishlist']);
|
||||
}
|
||||
|
||||
return Db::getInstance()->update('leofeature_wishlist', array('default' => '1'), 'id_wishlist = '.(int)$this->id);
|
||||
}
|
||||
|
||||
//DONGND:: delete product of wishlist
|
||||
public static function removeProductWishlist($id_wishlist, $id_wishlist_product)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_wishlist_product) || !Validate::isUnsignedId($id_wishlist)) {
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
return Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'leofeature_wishlist_product`
|
||||
WHERE `id_wishlist_product` = '.(int)($id_wishlist_product).'
|
||||
AND `id_wishlist` = '.(int)($id_wishlist));
|
||||
}
|
||||
|
||||
//DONGND:: delete product of wishlist
|
||||
public static function updateProductWishlist($id_wishlist, $id_wishlist_product, $priority, $quantity)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_wishlist_product) || !Validate::isUnsignedId($id_wishlist) || !Validate::isUnsignedInt($quantity) || !Validate::isUnsignedInt($priority) || $priority < 0 || $priority > 2) {
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
return Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'leofeature_wishlist_product` SET
|
||||
`priority` = '.(int)($priority).',
|
||||
`quantity` = '.(int)($quantity).'
|
||||
WHERE `id_wishlist` = '.(int)($id_wishlist).'
|
||||
AND `id_wishlist_product` = '.(int)($id_wishlist_product));
|
||||
}
|
||||
|
||||
//DONGND::
|
||||
public static function getSimpleProductByIdWishlist($id_wishlist)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_wishlist)) {
|
||||
die(Tools::displayError());
|
||||
}
|
||||
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT wp.*
|
||||
FROM `'._DB_PREFIX_.'leofeature_wishlist_product` wp
|
||||
WHERE wp.`id_wishlist` = '.(int)$id_wishlist.'');
|
||||
}
|
||||
}
|
||||
35
modules/leofeature/classes/index.php
Normal file
35
modules/leofeature/classes/index.php
Normal 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;
|
||||
Reference in New Issue
Block a user