// stocks : debug and optimisations
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9644 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
Vendored
+12
@@ -327,6 +327,8 @@
|
|||||||
'AdminCountriesController' => '',
|
'AdminCountriesController' => '',
|
||||||
'AdminCurrenciesControllerCore' => 'controllers/admin/AdminCurrenciesController.php',
|
'AdminCurrenciesControllerCore' => 'controllers/admin/AdminCurrenciesController.php',
|
||||||
'AdminCurrenciesController' => '',
|
'AdminCurrenciesController' => '',
|
||||||
|
'AdminCustomersControllerCore' => 'controllers/admin/AdminCustomersController.php',
|
||||||
|
'AdminCustomersController' => '',
|
||||||
'AdminDbControllerCore' => 'controllers/admin/AdminDbController.php',
|
'AdminDbControllerCore' => 'controllers/admin/AdminDbController.php',
|
||||||
'AdminDbController' => '',
|
'AdminDbController' => '',
|
||||||
'AdminDeliverySlipControllerCore' => 'controllers/admin/AdminDeliverySlipController.php',
|
'AdminDeliverySlipControllerCore' => 'controllers/admin/AdminDeliverySlipController.php',
|
||||||
@@ -343,8 +345,12 @@
|
|||||||
'AdminHomeControllerCore' => 'controllers/admin/AdminHomeController.php',
|
'AdminHomeControllerCore' => 'controllers/admin/AdminHomeController.php',
|
||||||
'AdminHomeController' => 'override/controllers/admin/AdminHomeController.php',
|
'AdminHomeController' => 'override/controllers/admin/AdminHomeController.php',
|
||||||
'AdminImagesController' => 'controllers/admin/AdminImagesController.php',
|
'AdminImagesController' => 'controllers/admin/AdminImagesController.php',
|
||||||
|
'AdminInformationControllerCore' => 'controllers/admin/AdminInformationController.php',
|
||||||
|
'AdminInformationController' => '',
|
||||||
'AdminInvoicesControllerCore' => 'controllers/admin/AdminInvoicesController.php',
|
'AdminInvoicesControllerCore' => 'controllers/admin/AdminInvoicesController.php',
|
||||||
'AdminInvoicesController' => '',
|
'AdminInvoicesController' => '',
|
||||||
|
'AdminLanguagesControllerCore' => 'controllers/admin/AdminLanguagesController.php',
|
||||||
|
'AdminLanguagesController' => '',
|
||||||
'AdminLogsControllerCore' => 'controllers/admin/AdminLogsController.php',
|
'AdminLogsControllerCore' => 'controllers/admin/AdminLogsController.php',
|
||||||
'AdminLogsController' => '',
|
'AdminLogsController' => '',
|
||||||
'AdminMetaControllerCore' => 'controllers/admin/AdminMetaController.php',
|
'AdminMetaControllerCore' => 'controllers/admin/AdminMetaController.php',
|
||||||
@@ -354,7 +360,13 @@
|
|||||||
'AdminOrdersController' => '',
|
'AdminOrdersController' => '',
|
||||||
'AdminPDFControllerCore' => 'controllers/admin/AdminPDFController.php',
|
'AdminPDFControllerCore' => 'controllers/admin/AdminPDFController.php',
|
||||||
'AdminPDFController' => '',
|
'AdminPDFController' => '',
|
||||||
|
'AdminPPreferencesControllerCore' => 'controllers/admin/AdminPPreferencesController.php',
|
||||||
|
'AdminPPreferencesController' => '',
|
||||||
|
'AdminPaymentControllerCore' => 'controllers/admin/AdminPaymentController.php',
|
||||||
|
'AdminPaymentController' => '',
|
||||||
'AdminProductsController' => 'controllers/admin/AdminProductsController.php',
|
'AdminProductsController' => 'controllers/admin/AdminProductsController.php',
|
||||||
|
'AdminProfilesControllerCore' => 'controllers/admin/AdminProfilesController.php',
|
||||||
|
'AdminProfilesController' => '',
|
||||||
'AdminQuickAccessesController' => 'controllers/admin/AdminQuickAccessesController.php',
|
'AdminQuickAccessesController' => 'controllers/admin/AdminQuickAccessesController.php',
|
||||||
'AdminRequestSqlControllerCore' => 'controllers/admin/AdminRequestSqlController.php',
|
'AdminRequestSqlControllerCore' => 'controllers/admin/AdminRequestSqlController.php',
|
||||||
'AdminRequestSqlController' => '',
|
'AdminRequestSqlController' => '',
|
||||||
|
|||||||
+1
-1
@@ -538,7 +538,7 @@ class OrderCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
protected function setProductCurrentStock(&$product)
|
protected function setProductCurrentStock(&$product)
|
||||||
{
|
{
|
||||||
$product['current_stock'] = StockManagerFactory::getManager()->getProductRealQuantities($product['product_id'], $product['product_attribute_id'], null, true);
|
$product['current_stock'] = StockManagerFactory::getManager()->getProductPhysicalQuantities($product['product_id'], $product['product_attribute_id'], null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+9
-6
@@ -2085,7 +2085,7 @@ class ProductCore extends ObjectModel
|
|||||||
else if (is_string($productAttribute))
|
else if (is_string($productAttribute))
|
||||||
$sql->where('stock.id_product_attribute = IFNULL('.pSQL($productAttribute).'.id_product_attribute, 0)');
|
$sql->where('stock.id_product_attribute = IFNULL('.pSQL($productAttribute).'.id_product_attribute, 0)');
|
||||||
}
|
}
|
||||||
$sql->where(ltrim($shop->addSqlRestriction(Shop::SHARE_STOCK, 'stock'), ' AND '));
|
$sql->where(ltrim($shop->addSqlRestriction(false, 'stock'), ' AND '));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2099,7 +2099,7 @@ class ProductCore extends ObjectModel
|
|||||||
else if (is_string($productAttribute))
|
else if (is_string($productAttribute))
|
||||||
$sql .= ' AND stock.id_product_attribute = IFNULL('.pSQL($productAttribute).'.id_product_attribute, 0)';
|
$sql .= ' AND stock.id_product_attribute = IFNULL('.pSQL($productAttribute).'.id_product_attribute, 0)';
|
||||||
}
|
}
|
||||||
$sql .= $shop->addSqlRestriction(Shop::SHARE_STOCK, 'stock').' ';
|
$sql .= $shop->addSqlRestriction(false, 'stock').' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sql;
|
return $sql;
|
||||||
@@ -2125,7 +2125,7 @@ class ProductCore extends ObjectModel
|
|||||||
FROM '._DB_PREFIX_.'stock_available
|
FROM '._DB_PREFIX_.'stock_available
|
||||||
WHERE id_product = '.$this->id.'
|
WHERE id_product = '.$this->id.'
|
||||||
AND id_product_attribute = 0'.
|
AND id_product_attribute = 0'.
|
||||||
$context->shop->addSqlRestriction(Shop::SHARE_STOCK);
|
$context->shop->addSqlRestriction();
|
||||||
return (int)Db::getInstance()->getValue($sql);
|
return (int)Db::getInstance()->getValue($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2149,7 +2149,7 @@ class ProductCore extends ObjectModel
|
|||||||
FROM '._DB_PREFIX_.'stock_available
|
FROM '._DB_PREFIX_.'stock_available
|
||||||
WHERE id_product = '.$this->id.'
|
WHERE id_product = '.$this->id.'
|
||||||
AND id_product_attribute = 0'.
|
AND id_product_attribute = 0'.
|
||||||
$context->shop->addSqlRestriction(Shop::SHARE_STOCK);
|
$context->shop->addSqlRestriction();
|
||||||
return (int)Db::getInstance()->getValue($sql);
|
return (int)Db::getInstance()->getValue($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2157,7 +2157,7 @@ class ProductCore extends ObjectModel
|
|||||||
* Update available product quantities
|
* Update available product quantities
|
||||||
*
|
*
|
||||||
* @deprecated since 1.5.0
|
* @deprecated since 1.5.0
|
||||||
*
|
*
|
||||||
* @param array $product Array with ordered product (quantity, id_product_attribute if applicable)
|
* @param array $product Array with ordered product (quantity, id_product_attribute if applicable)
|
||||||
* @return mixed Query result
|
* @return mixed Query result
|
||||||
*/
|
*/
|
||||||
@@ -2185,6 +2185,9 @@ class ProductCore extends ObjectModel
|
|||||||
return $productObj->addStockMvt(-(int)$product['cart_quantity'], (int)_STOCK_MOVEMENT_ORDER_REASON_, (int)$product['id_product_attribute'], (int)$id_order, null);
|
return $productObj->addStockMvt(-(int)$product['cart_quantity'], (int)_STOCK_MOVEMENT_ORDER_REASON_, (int)$product['id_product_attribute'], (int)$id_order, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since 1.5.0
|
||||||
|
*/
|
||||||
public static function reinjectQuantities(&$orderDetail, $quantity, Context $context = null)
|
public static function reinjectQuantities(&$orderDetail, $quantity, Context $context = null)
|
||||||
{
|
{
|
||||||
if (!$context)
|
if (!$context)
|
||||||
@@ -2227,7 +2230,7 @@ class ProductCore extends ObjectModel
|
|||||||
|
|
||||||
if ($this->isAvailableWhenOutOfStock($this->getOutOfStock()))
|
if ($this->isAvailableWhenOutOfStock($this->getOutOfStock()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(isset($this->id_product_attribute))
|
if(isset($this->id_product_attribute))
|
||||||
$id_product_attribute = $this->id_product_attribute;
|
$id_product_attribute = $this->id_product_attribute;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* 2007-2011 PrestaShop
|
* 2007-2011 PrestaShop
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* NOTICE OF LICENSE
|
||||||
*
|
*
|
||||||
@@ -34,15 +34,13 @@ class GroupShopCore extends ObjectModel
|
|||||||
public $active;
|
public $active;
|
||||||
public $share_customer;
|
public $share_customer;
|
||||||
public $share_order;
|
public $share_order;
|
||||||
public $share_stock;
|
|
||||||
public $deleted;
|
public $deleted;
|
||||||
|
|
||||||
protected $fieldsSize = array('name' => 64);
|
protected $fieldsSize = array('name' => 64);
|
||||||
protected $fieldsValidate = array(
|
protected $fieldsValidate = array(
|
||||||
'active' => 'isBool',
|
'active' => 'isBool',
|
||||||
'share_customer' => 'isBool',
|
'share_customer' => 'isBool',
|
||||||
'share_order' => 'isBool',
|
'share_order' => 'isBool',
|
||||||
'share_stock' => 'isBool',
|
|
||||||
'name' => 'isGenericName',
|
'name' => 'isGenericName',
|
||||||
);
|
);
|
||||||
protected $table = 'group_shop';
|
protected $table = 'group_shop';
|
||||||
@@ -51,7 +49,6 @@ class GroupShopCore extends ObjectModel
|
|||||||
private static $assoTables = array(
|
private static $assoTables = array(
|
||||||
'attribute_group' => array('type' => 'group_shop'),
|
'attribute_group' => array('type' => 'group_shop'),
|
||||||
'attribute' => array('type' => 'group_shop'),
|
'attribute' => array('type' => 'group_shop'),
|
||||||
//'customer_group' => array('type' => 'group_shop'),
|
|
||||||
'feature' => array('type' => 'group_shop'),
|
'feature' => array('type' => 'group_shop'),
|
||||||
'group' => array('type' => 'group_shop'),
|
'group' => array('type' => 'group_shop'),
|
||||||
'manufacturer' => array('type' => 'group_shop'),
|
'manufacturer' => array('type' => 'group_shop'),
|
||||||
@@ -66,20 +63,19 @@ class GroupShopCore extends ObjectModel
|
|||||||
|
|
||||||
$fields['name'] = pSQL($this->name);
|
$fields['name'] = pSQL($this->name);
|
||||||
$fields['share_customer'] = (int)$this->share_customer;
|
$fields['share_customer'] = (int)$this->share_customer;
|
||||||
$fields['share_stock'] = (int)$this->share_stock;
|
$fields['share_order'] = ($fields['share_customer']) ? (int)$this->share_order : false;
|
||||||
$fields['share_order'] = ($fields['share_customer'] && $fields['share_stock']) ? (int)$this->share_order : false;
|
|
||||||
$fields['active'] = (int)$this->active;
|
$fields['active'] = (int)$this->active;
|
||||||
$fields['deleted'] = (int)$this->deleted;
|
$fields['deleted'] = (int)$this->deleted;
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getGroupShops($active = true)
|
public static function getGroupShops($active = true)
|
||||||
{
|
{
|
||||||
return Db::getInstance()->executeS('SELECT *
|
return Db::getInstance()->executeS('SELECT *
|
||||||
FROM '._DB_PREFIX_.'group_shop
|
FROM '._DB_PREFIX_.'group_shop
|
||||||
WHERE `deleted`= 0 AND `active`='.(int)$active);
|
WHERE `deleted`= 0 AND `active`='.(int)$active);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
if (!$res = parent::delete())
|
if (!$res = parent::delete())
|
||||||
@@ -126,7 +122,7 @@ class GroupShopCore extends ObjectModel
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a group shop ID from group shop name
|
* Return a group shop ID from group shop name
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
@@ -137,7 +133,7 @@ class GroupShopCore extends ObjectModel
|
|||||||
WHERE name = \''.pSQL($name).'\'';
|
WHERE name = \''.pSQL($name).'\'';
|
||||||
return (int)Db::getInstance()->getValue($sql);
|
return (int)Db::getInstance()->getValue($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function copyGroupShopData($old_id, $tables_import = false, $deleted = false)
|
public function copyGroupShopData($old_id, $tables_import = false, $deleted = false)
|
||||||
{
|
{
|
||||||
foreach (GroupShop::getAssoTables() AS $table_name => $row)
|
foreach (GroupShop::getAssoTables() AS $table_name => $row)
|
||||||
|
|||||||
+4
-15
@@ -79,7 +79,6 @@ class ShopCore extends ObjectModel
|
|||||||
'module_currency' => array('type' => 'fk_shop'),
|
'module_currency' => array('type' => 'fk_shop'),
|
||||||
'module_country' => array('type' => 'fk_shop'),
|
'module_country' => array('type' => 'fk_shop'),
|
||||||
'module_group' => array('type' => 'fk_shop'),
|
'module_group' => array('type' => 'fk_shop'),
|
||||||
//'stock' => array('type' => 'fk_shop', 'primary' => 'id_stock'),
|
|
||||||
'product' => array('type' => 'shop'),
|
'product' => array('type' => 'shop'),
|
||||||
'product_lang' => array('type' => 'fk_shop'),
|
'product_lang' => array('type' => 'fk_shop'),
|
||||||
'referrer' => array('type' => 'shop'),
|
'referrer' => array('type' => 'shop'),
|
||||||
@@ -108,7 +107,6 @@ class ShopCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
const SHARE_CUSTOMER = 'share_customer';
|
const SHARE_CUSTOMER = 'share_customer';
|
||||||
const SHARE_ORDER = 'share_order';
|
const SHARE_ORDER = 'share_order';
|
||||||
const SHARE_STOCK = 'share_stock';
|
|
||||||
|
|
||||||
public function getFields()
|
public function getFields()
|
||||||
{
|
{
|
||||||
@@ -162,14 +160,6 @@ class ShopCore extends ObjectModel
|
|||||||
|
|
||||||
foreach (Shop::getAssoTables() as $table_name => $row)
|
foreach (Shop::getAssoTables() as $table_name => $row)
|
||||||
{
|
{
|
||||||
// Special case for stock if current shop is in a share stock group
|
|
||||||
/*if ($table_name == 'stock')
|
|
||||||
{
|
|
||||||
$group = new GroupShop($this->id_group_shop);
|
|
||||||
if ($group->share_stock && $group->getTotalShops() > 1)
|
|
||||||
continue;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
$id = 'id_'.$row['type'];
|
$id = 'id_'.$row['type'];
|
||||||
if ($row['type'] == 'fk_shop')
|
if ($row['type'] == 'fk_shop')
|
||||||
$id = 'id_shop';
|
$id = 'id_shop';
|
||||||
@@ -410,7 +400,6 @@ class ShopCore extends ObjectModel
|
|||||||
'name' => $row['group_name'],
|
'name' => $row['group_name'],
|
||||||
'share_customer' => $row['share_customer'],
|
'share_customer' => $row['share_customer'],
|
||||||
'share_order' => $row['share_order'],
|
'share_order' => $row['share_order'],
|
||||||
'share_stock' => $row['share_stock'],
|
|
||||||
'totalShops' => self::getTotalShopsByIdGroupShop($row['id_group_shop']),
|
'totalShops' => self::getTotalShopsByIdGroupShop($row['id_group_shop']),
|
||||||
'shops' => array(),
|
'shops' => array(),
|
||||||
);
|
);
|
||||||
@@ -537,12 +526,12 @@ class ShopCore extends ObjectModel
|
|||||||
* If the shop group has the option $type activated, get all shops ID of this group, else get current shop ID
|
* If the shop group has the option $type activated, get all shops ID of this group, else get current shop ID
|
||||||
*
|
*
|
||||||
* @param int $shop_id
|
* @param int $shop_id
|
||||||
* @param int $type Shop::SHARE_CUSTOMER | Shop::SHARE_ORDER | Shop::SHARE_STOCK
|
* @param int $type Shop::SHARE_CUSTOMER | Shop::SHARE_ORDER
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getSharedShops($shop_id, $type)
|
public static function getSharedShops($shop_id, $type)
|
||||||
{
|
{
|
||||||
if (!in_array($type, array(Shop::SHARE_CUSTOMER, Shop::SHARE_ORDER, Shop::SHARE_STOCK)))
|
if (!in_array($type, array(Shop::SHARE_CUSTOMER, Shop::SHARE_ORDER)))
|
||||||
die('Wrong argument ($type) in Shop::getSharedShops() method');
|
die('Wrong argument ($type) in Shop::getSharedShops() method');
|
||||||
|
|
||||||
Shop::cacheShops();
|
Shop::cacheShops();
|
||||||
@@ -670,8 +659,8 @@ class ShopCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
if ($shop_id || $shop_group_id)
|
if ($shop_id || $shop_group_id)
|
||||||
$restriction = ' AND '.$alias.'id_shop IN ('.implode(', ', $this->getListOfID($share)).') ';
|
$restriction = ' AND '.$alias.'id_shop IN ('.implode(', ', $this->getListOfID($share)).') ';
|
||||||
else if ($share == Shop::SHARE_STOCK)
|
//else if ($share == Shop::SHARE_STOCK)
|
||||||
$restriction = ' AND '.$alias.'id_shop = '.$this->getID(true);
|
// $restriction = ' AND '.$alias.'id_shop = '.$this->getID(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $restriction;
|
return $restriction;
|
||||||
|
|||||||
@@ -83,27 +83,6 @@ class AdminGroupShopControllerCore extends AdminController
|
|||||||
),
|
),
|
||||||
'p' => $this->l('Share customers between shops of this group')
|
'p' => $this->l('Share customers between shops of this group')
|
||||||
),
|
),
|
||||||
array(
|
|
||||||
'type' => 'radio',
|
|
||||||
'label' => $this->l('Share stock:'),
|
|
||||||
'name' => 'share_stock',
|
|
||||||
'required' => true,
|
|
||||||
'class' => 't',
|
|
||||||
'is_bool' => true,
|
|
||||||
'values' => array(
|
|
||||||
array(
|
|
||||||
'id' => 'share_stock_on',
|
|
||||||
'value' => 1,
|
|
||||||
'label' => $this->l('Enabled')
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'id' => 'share_stock_off',
|
|
||||||
'value' => 0,
|
|
||||||
'label' => $this->l('Disabled')
|
|
||||||
)
|
|
||||||
),
|
|
||||||
'p' => $this->l('Share stock between shops of this group')
|
|
||||||
),
|
|
||||||
array(
|
array(
|
||||||
'type' => 'radio',
|
'type' => 'radio',
|
||||||
'label' => $this->l('Share orders:'),
|
'label' => $this->l('Share orders:'),
|
||||||
@@ -159,7 +138,6 @@ class AdminGroupShopControllerCore extends AdminController
|
|||||||
if (Shop::getTotalShops() > 1 && $obj->id)
|
if (Shop::getTotalShops() > 1 && $obj->id)
|
||||||
$disabled = array(
|
$disabled = array(
|
||||||
'share_customer' => true,
|
'share_customer' => true,
|
||||||
'share_stock' => true,
|
|
||||||
'share_order' => true,
|
'share_order' => true,
|
||||||
'active' => false
|
'active' => false
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ class AdminProductsController extends AdminController
|
|||||||
'name_category' => array('title' => $this->l('Category'), 'width' => 100, 'filter_key' => 'cl!name'),
|
'name_category' => array('title' => $this->l('Category'), 'width' => 100, 'filter_key' => 'cl!name'),
|
||||||
'price' => array('title' => $this->l('Base price'), 'width' => 70, 'price' => true, 'align' => 'right', 'filter_key' => 'a!price'),
|
'price' => array('title' => $this->l('Base price'), 'width' => 70, 'price' => true, 'align' => 'right', 'filter_key' => 'a!price'),
|
||||||
'price_final' => array('title' => $this->l('Final price'), 'width' => 70, 'price' => true, 'align' => 'right', 'havingFilter' => true, 'orderby' => false),
|
'price_final' => array('title' => $this->l('Final price'), 'width' => 70, 'price' => true, 'align' => 'right', 'havingFilter' => true, 'orderby' => false),
|
||||||
'quantity' => array('title' => $this->l('Quantity'), 'width' => 30, 'align' => 'right', 'filter_key' => 'a!quantity', 'type' => 'decimal'),
|
|
||||||
'active' => array('title' => $this->l('Displayed'), 'active' => 'status', 'filter_key' => 'a!active', 'align' => 'center', 'type' => 'bool', 'orderby' => false),
|
'active' => array('title' => $this->l('Displayed'), 'active' => 'status', 'filter_key' => 'a!active', 'align' => 'center', 'type' => 'bool', 'orderby' => false),
|
||||||
'position' => array('title' => $this->l('Position'), 'width' => 40,'filter_key' => 'cp!position', 'align' => 'center', 'position' => 'position'),
|
'position' => array('title' => $this->l('Position'), 'width' => 40,'filter_key' => 'cp!position', 'align' => 'center', 'position' => 'position'),
|
||||||
);
|
);
|
||||||
@@ -70,14 +69,14 @@ class AdminProductsController extends AdminController
|
|||||||
else
|
else
|
||||||
$this->_category = new Category(1);
|
$this->_category = new Category(1);
|
||||||
|
|
||||||
$this->_join = Product::sqlStock('a').'
|
$this->_join = '
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (a.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang`)
|
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (a.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang`)
|
||||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = a.`id_product` AND i.`cover` = 1)
|
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = a.`id_product` AND i.`cover` = 1)
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = a.`id_product`)
|
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = a.`id_product`)
|
||||||
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (a.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = '.(int)$this->context->country->id.' AND tr.`id_state` = 0)
|
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (a.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = '.(int)$this->context->country->id.' AND tr.`id_state` = 0)
|
||||||
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)';
|
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)';
|
||||||
$this->_filter = 'AND cp.`id_category` = '.(int)($this->_category->id);
|
$this->_filter = 'AND cp.`id_category` = '.(int)($this->_category->id);
|
||||||
$this->_select = 'cl.name `name_category`, cp.`position`, i.`id_image`, (a.`price` * ((100 + (t.`rate`))/100)) AS price_final, SUM(stock.quantity) AS quantity';
|
$this->_select = 'cl.name `name_category`, cp.`position`, i.`id_image`, (a.`price` * ((100 + (t.`rate`))/100)) AS price_final';
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* 2007-2011 PrestaShop
|
* 2007-2011 PrestaShop
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* NOTICE OF LICENSE
|
||||||
*
|
*
|
||||||
@@ -48,7 +48,7 @@ class MailAlerts extends Module
|
|||||||
$this->author = 'PrestaShop';
|
$this->author = 'PrestaShop';
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
if ($this->id)
|
if ($this->id)
|
||||||
$this->_refreshProperties();
|
$this->_refreshProperties();
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ class MailAlerts extends Module
|
|||||||
return false;
|
return false;
|
||||||
return parent::uninstall();
|
return parent::uninstall();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _refreshProperties()
|
private function _refreshProperties()
|
||||||
{
|
{
|
||||||
$this->_merchant_mails = Configuration::get('MA_MERCHANT_MAILS');
|
$this->_merchant_mails = Configuration::get('MA_MERCHANT_MAILS');
|
||||||
@@ -133,7 +133,7 @@ class MailAlerts extends Module
|
|||||||
$message = $this->l('No message');
|
$message = $this->l('No message');
|
||||||
|
|
||||||
$itemsTable = '';
|
$itemsTable = '';
|
||||||
|
|
||||||
$products = $params['order']->getProducts();
|
$products = $params['order']->getProducts();
|
||||||
$customizedDatas = Product::getAllCustomizedDatas(intval($params['cart']->id));
|
$customizedDatas = Product::getAllCustomizedDatas(intval($params['cart']->id));
|
||||||
Product::addCustomizationPrice($products, $customizedDatas);
|
Product::addCustomizationPrice($products, $customizedDatas);
|
||||||
@@ -141,7 +141,7 @@ class MailAlerts extends Module
|
|||||||
{
|
{
|
||||||
$unit_price = $product['product_price_wt'];
|
$unit_price = $product['product_price_wt'];
|
||||||
$price = $product['total_price'];
|
$price = $product['total_price'];
|
||||||
|
|
||||||
$customizationText = '';
|
$customizationText = '';
|
||||||
if (isset($customizedDatas[$product['product_id']][$product['product_attribute_id']]))
|
if (isset($customizedDatas[$product['product_id']][$product['product_attribute_id']]))
|
||||||
{
|
{
|
||||||
@@ -151,16 +151,16 @@ class MailAlerts extends Module
|
|||||||
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD]))
|
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD]))
|
||||||
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] AS $text)
|
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] AS $text)
|
||||||
$customizationText .= $text['name'].':'.' '.$text['value'].'<br />';
|
$customizationText .= $text['name'].':'.' '.$text['value'].'<br />';
|
||||||
|
|
||||||
if (isset($customization['datas'][Product::CUSTOMIZE_FILE]))
|
if (isset($customization['datas'][Product::CUSTOMIZE_FILE]))
|
||||||
$customizationText .= sizeof($customization['datas'][Product::CUSTOMIZE_FILE]) .' '. Tools::displayError('image(s)').'<br />';
|
$customizationText .= sizeof($customization['datas'][Product::CUSTOMIZE_FILE]) .' '. Tools::displayError('image(s)').'<br />';
|
||||||
|
|
||||||
$customizationText .= '---<br />';
|
$customizationText .= '---<br />';
|
||||||
}
|
}
|
||||||
|
|
||||||
$customizationText = rtrim($customizationText, '---<br />');
|
$customizationText = rtrim($customizationText, '---<br />');
|
||||||
}
|
}
|
||||||
|
|
||||||
$itemsTable .=
|
$itemsTable .=
|
||||||
'<tr style="background-color:'.($key % 2 ? '#DDE2E6' : '#EBECEE').';">
|
'<tr style="background-color:'.($key % 2 ? '#DDE2E6' : '#EBECEE').';">
|
||||||
<td style="padding:0.6em 0.4em;">'.$product['product_reference'].'</td>
|
<td style="padding:0.6em 0.4em;">'.$product['product_reference'].'</td>
|
||||||
@@ -192,11 +192,11 @@ class MailAlerts extends Module
|
|||||||
'{email}' => $customer->email,
|
'{email}' => $customer->email,
|
||||||
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
|
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
|
||||||
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
|
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
|
||||||
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, "<br />",
|
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, "<br />",
|
||||||
array(
|
array(
|
||||||
'firstname' => '<span style="color:#DB3484; font-weight:bold;">%s</span>',
|
'firstname' => '<span style="color:#DB3484; font-weight:bold;">%s</span>',
|
||||||
'lastname' => '<span style="color:#DB3484; font-weight:bold;">%s</span>')),
|
'lastname' => '<span style="color:#DB3484; font-weight:bold;">%s</span>')),
|
||||||
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, "<br />",
|
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, "<br />",
|
||||||
array(
|
array(
|
||||||
'firstname' => '<span style="color:#DB3484; font-weight:bold;">%s</span>',
|
'firstname' => '<span style="color:#DB3484; font-weight:bold;">%s</span>',
|
||||||
'lastname' => '<span style="color:#DB3484; font-weight:bold;">%s</span>')),
|
'lastname' => '<span style="color:#DB3484; font-weight:bold;">%s</span>')),
|
||||||
@@ -277,10 +277,10 @@ class MailAlerts extends Module
|
|||||||
public function customerHasNotification($id_customer, $id_product, $id_product_attribute)
|
public function customerHasNotification($id_customer, $id_product, $id_product_attribute)
|
||||||
{
|
{
|
||||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `'._DB_PREFIX_.'mailalert_customer_oos`
|
FROM `'._DB_PREFIX_.'mailalert_customer_oos`
|
||||||
WHERE `id_customer` = '.(int)($id_customer).'
|
WHERE `id_customer` = '.(int)($id_customer).'
|
||||||
AND `id_product` = '.(int)($id_product).'
|
AND `id_product` = '.(int)($id_product).'
|
||||||
AND `id_product_attribute` = '.(int)($id_product_attribute));
|
AND `id_product_attribute` = '.(int)($id_product_attribute));
|
||||||
return sizeof($result);
|
return sizeof($result);
|
||||||
}
|
}
|
||||||
@@ -327,20 +327,20 @@ class MailAlerts extends Module
|
|||||||
$sql = 'SELECT id_product, quantity
|
$sql = 'SELECT id_product, quantity
|
||||||
FROM '._DB_PREFIX_.'stock_available
|
FROM '._DB_PREFIX_.'stock_available
|
||||||
WHERE id_product_attribute = '.(int)$params['id_product_attribute']
|
WHERE id_product_attribute = '.(int)$params['id_product_attribute']
|
||||||
.Context::getContext()->shop->addSqlRestriction(Shop::SHARE_STOCK);
|
.Context::getContext()->shop->addSqlRestriction();
|
||||||
$result = Db::getInstance()->getRow($sql);
|
$result = Db::getInstance()->getRow($sql);
|
||||||
|
|
||||||
if ($this->_customer_qty AND $result['quantity'] > 0)
|
if ($this->_customer_qty AND $result['quantity'] > 0)
|
||||||
$this->sendCustomerAlert((int)$result['id_product'], (int)$params['id_product_attribute']);
|
$this->sendCustomerAlert((int)$result['id_product'], (int)$params['id_product_attribute']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendCustomerAlert($id_product, $id_product_attribute)
|
public function sendCustomerAlert($id_product, $id_product_attribute)
|
||||||
{
|
{
|
||||||
$customers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
$customers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||||
SELECT id_customer, customer_email
|
SELECT id_customer, customer_email
|
||||||
FROM `'._DB_PREFIX_.'mailalert_customer_oos`
|
FROM `'._DB_PREFIX_.'mailalert_customer_oos`
|
||||||
WHERE `id_product` = '.(int)$id_product.' AND `id_product_attribute` = '.(int)$id_product_attribute);
|
WHERE `id_product` = '.(int)$id_product.' AND `id_product_attribute` = '.(int)$id_product_attribute);
|
||||||
|
|
||||||
$product = new Product((int)$id_product, false, $this->context->language->id);
|
$product = new Product((int)$id_product, false, $this->context->language->id);
|
||||||
$templateVars = array(
|
$templateVars = array(
|
||||||
'{product}' => (is_array($product->name) ? $product->name[(int)Configuration::get('PS_LANG_DEFAULT')] : $product->name),
|
'{product}' => (is_array($product->name) ? $product->name[(int)Configuration::get('PS_LANG_DEFAULT')] : $product->name),
|
||||||
@@ -368,12 +368,12 @@ class MailAlerts extends Module
|
|||||||
self::deleteAlert((int)$customer_id, strval($customer_email), (int)$id_product, (int)$id_product_attribute);
|
self::deleteAlert((int)$customer_id, strval($customer_email), (int)$id_product, (int)$id_product_attribute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hookCustomerAccount($params)
|
public function hookCustomerAccount($params)
|
||||||
{
|
{
|
||||||
return $this->_customer_qty ? $this->display(__FILE__, 'my-account.tpl') : NULL;
|
return $this->_customer_qty ? $this->display(__FILE__, 'my-account.tpl') : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hookMyAccountBlock($params)
|
public function hookMyAccountBlock($params)
|
||||||
{
|
{
|
||||||
return $this->hookCustomerAccount($params);
|
return $this->hookCustomerAccount($params);
|
||||||
@@ -525,7 +525,7 @@ class MailAlerts extends Module
|
|||||||
foreach ($result AS $k => $row)
|
foreach ($result AS $k => $row)
|
||||||
$products[$i]['attributes_small'] .= $row['attribute_name'].', ';
|
$products[$i]['attributes_small'] .= $row['attribute_name'].', ';
|
||||||
$products[$i]['attributes_small'] = rtrim($products[$i]['attributes_small'], ', ');
|
$products[$i]['attributes_small'] = rtrim($products[$i]['attributes_small'], ', ');
|
||||||
|
|
||||||
// cover
|
// cover
|
||||||
$attrgrps = $obj->getAttributesGroups($id_lang);
|
$attrgrps = $obj->getAttributesGroups($id_lang);
|
||||||
foreach ($attrgrps AS $attrgrp)
|
foreach ($attrgrps AS $attrgrp)
|
||||||
@@ -556,18 +556,18 @@ class MailAlerts extends Module
|
|||||||
public static function deleteAlert($id_customer, $customer_email, $id_product, $id_product_attribute)
|
public static function deleteAlert($id_customer, $customer_email, $id_product, $id_product_attribute)
|
||||||
{
|
{
|
||||||
return Db::getInstance()->execute('
|
return Db::getInstance()->execute('
|
||||||
DELETE FROM `'._DB_PREFIX_.'mailalert_customer_oos`
|
DELETE FROM `'._DB_PREFIX_.'mailalert_customer_oos`
|
||||||
WHERE `id_customer` = '.(int)($id_customer).'
|
WHERE `id_customer` = '.(int)($id_customer).'
|
||||||
AND `customer_email` = \''.pSQL($customer_email).'\'
|
AND `customer_email` = \''.pSQL($customer_email).'\'
|
||||||
AND `id_product` = '.(int)($id_product).'
|
AND `id_product` = '.(int)($id_product).'
|
||||||
AND `id_product_attribute` = '.(int)($id_product_attribute));
|
AND `id_product_attribute` = '.(int)($id_product_attribute));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hookDeleteProduct($params)
|
public function hookDeleteProduct($params)
|
||||||
{
|
{
|
||||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'mailalert_customer_oos` WHERE `id_product` = '.(int)$params['product']->id);
|
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'mailalert_customer_oos` WHERE `id_product` = '.(int)$params['product']->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hookDeleteProductAttribute($params)
|
public function hookDeleteProductAttribute($params)
|
||||||
{
|
{
|
||||||
if ($params['deleteAllAttributes'])
|
if ($params['deleteAllAttributes'])
|
||||||
@@ -575,7 +575,7 @@ class MailAlerts extends Module
|
|||||||
WHERE `id_product` = '.(int)$params['id_product']);
|
WHERE `id_product` = '.(int)$params['id_product']);
|
||||||
else
|
else
|
||||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'mailalert_customer_oos`
|
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'mailalert_customer_oos`
|
||||||
WHERE `id_product_attribute` = '.(int)$params['id_product_attribute'].'
|
WHERE `id_product_attribute` = '.(int)$params['id_product_attribute'].'
|
||||||
AND `id_product` = '.(int)$params['id_product']);
|
AND `id_product` = '.(int)$params['id_product']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user