// id_shop on cart product (for links) + change Shop::sqlAsso() + share_order
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@7687 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -200,7 +200,7 @@ class CMSCategoryCore extends ObjectModel
|
||||
|
||||
$sql = 'SELECT c.`id_cms`, cl.`meta_title`, cl.`link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'cms` c
|
||||
'.$context->shop->sqlAsso('cms', 'c').'
|
||||
'.$context->shop->sqlAsso('cms', 'c', false).'
|
||||
JOIN `'._DB_PREFIX_.'cms_lang` cl ON c.`id_cms` = cl.`id_cms`
|
||||
WHERE `id_cms_category` = '.(int)$current.'
|
||||
AND cl.`id_lang` = '.$id_lang.($active ? ' AND c.`active` = 1' : '').'
|
||||
|
||||
+50
-45
@@ -318,7 +318,7 @@ class CartCore extends ObjectModel
|
||||
public function getLastProduct()
|
||||
{
|
||||
$sql = '
|
||||
SELECT `id_product`, `id_product_attribute`
|
||||
SELECT `id_product`, `id_product_attribute`, id_shop
|
||||
FROM `'._DB_PREFIX_.'cart_product`
|
||||
WHERE `id_cart` = '.(int)($this->id).'
|
||||
ORDER BY `date_add` DESC';
|
||||
@@ -353,46 +353,45 @@ class CartCore extends ObjectModel
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
$sql = '
|
||||
SELECT cp.`id_product_attribute`, cp.`id_product`, cu.`id_customization`, cp.`quantity` AS cart_quantity, cu.`quantity` AS customization_quantity, pl.`name`,
|
||||
pl.`description_short`, pl.`available_now`, pl.`available_later`, p.`id_product`, p.`id_category_default`, p.`id_supplier`, p.`id_manufacturer`, p.`on_sale`, p.`ecotax`, p.`additional_shipping_cost`, p.`available_for_order`,
|
||||
p.`price`, p.`weight`, p.`width`, p.`height`, p.`depth`, p.`out_of_stock`, p.`active`, p.`date_add`, p.`date_upd`, IFNULL(pa.`minimal_quantity`, p.`minimal_quantity`) as minimal_quantity,
|
||||
t.`id_tax`, tl.`name` AS tax, t.`rate`, pa.`price` AS price_attribute, stock.quantity,
|
||||
pa.`ecotax` AS ecotax_attr, i.`id_image`, il.`legend`, pl.`link_rewrite`, cl.`link_rewrite` AS category, CONCAT(cp.`id_product`, cp.`id_product_attribute`) AS unique_id,
|
||||
IF (IFNULL(pa.`reference`, \'\') = \'\', p.`reference`, pa.`reference`) AS reference,
|
||||
IF (IFNULL(pa.`supplier_reference`, \'\') = \'\', p.`supplier_reference`, pa.`supplier_reference`) AS supplier_reference,
|
||||
(p.`weight`+ pa.`weight`) weight_attribute,
|
||||
IF (IFNULL(pa.`ean13`, \'\') = \'\', p.`ean13`, pa.`ean13`) AS ean13, IF (IFNULL(pa.`upc`, \'\') = \'\', p.`upc`, pa.`upc`) AS upc,
|
||||
pai.`id_image` as pai_id_image
|
||||
FROM `'._DB_PREFIX_.'cart_product` cp
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product`
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$this->id_lang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pa.`id_product_attribute` = cp.`id_product_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
|
||||
AND tr.`id_country` = '.(int)$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_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = '.(int)$this->id_lang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'customization` cu ON (p.`id_product` = cu.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_image` pai ON (pai.`id_product_attribute` = pa.`id_product_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (IF(pai.`id_image`,
|
||||
i.`id_image` =
|
||||
(SELECT i2.`id_image`
|
||||
FROM `'._DB_PREFIX_.'image` i2
|
||||
INNER JOIN `'._DB_PREFIX_.'product_attribute_image` pai2 ON (pai2.`id_image` = i2.`id_image`)
|
||||
WHERE i2.`id_product` = p.`id_product` AND pai2.`id_product_attribute` = pa.`id_product_attribute`
|
||||
ORDER BY i2.`position`
|
||||
LIMIT 1),
|
||||
i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$this->id_lang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.(int)$this->id_lang.')
|
||||
'.Product::sqlStock('cp', 'cp').'
|
||||
WHERE cp.`id_cart` = '.(int)$this->id.'
|
||||
'.($id_product ? ' AND cp.`id_product` = '.(int)$id_product : '').'
|
||||
AND p.`id_product` IS NOT NULL
|
||||
GROUP BY unique_id
|
||||
ORDER BY cp.date_add ASC';
|
||||
$sql = 'SELECT cp.`id_product_attribute`, cp.`id_product`, cu.`id_customization`, cp.`quantity` AS cart_quantity, cp.id_shop, cu.`quantity` AS customization_quantity, pl.`name`,
|
||||
pl.`description_short`, pl.`available_now`, pl.`available_later`, p.`id_product`, p.`id_category_default`, p.`id_supplier`, p.`id_manufacturer`, p.`on_sale`, p.`ecotax`, p.`additional_shipping_cost`, p.`available_for_order`,
|
||||
p.`price`, p.`weight`, p.`width`, p.`height`, p.`depth`, p.`out_of_stock`, p.`active`, p.`date_add`, p.`date_upd`, IFNULL(pa.`minimal_quantity`, p.`minimal_quantity`) as minimal_quantity,
|
||||
t.`id_tax`, tl.`name` AS tax, t.`rate`, pa.`price` AS price_attribute, stock.quantity,
|
||||
pa.`ecotax` AS ecotax_attr, i.`id_image`, il.`legend`, pl.`link_rewrite`, cl.`link_rewrite` AS category, CONCAT(cp.`id_product`, cp.`id_product_attribute`) AS unique_id,
|
||||
IF (IFNULL(pa.`reference`, \'\') = \'\', p.`reference`, pa.`reference`) AS reference,
|
||||
IF (IFNULL(pa.`supplier_reference`, \'\') = \'\', p.`supplier_reference`, pa.`supplier_reference`) AS supplier_reference,
|
||||
(p.`weight`+ pa.`weight`) weight_attribute,
|
||||
IF (IFNULL(pa.`ean13`, \'\') = \'\', p.`ean13`, pa.`ean13`) AS ean13, IF (IFNULL(pa.`upc`, \'\') = \'\', p.`upc`, pa.`upc`) AS upc,
|
||||
pai.`id_image` as pai_id_image
|
||||
FROM `'._DB_PREFIX_.'cart_product` cp
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product`
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$this->id_lang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pa.`id_product_attribute` = cp.`id_product_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
|
||||
AND tr.`id_country` = '.(int)$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_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = '.(int)$this->id_lang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'customization` cu ON (p.`id_product` = cu.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_image` pai ON (pai.`id_product_attribute` = pa.`id_product_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (IF(pai.`id_image`,
|
||||
i.`id_image` =
|
||||
(SELECT i2.`id_image`
|
||||
FROM `'._DB_PREFIX_.'image` i2
|
||||
INNER JOIN `'._DB_PREFIX_.'product_attribute_image` pai2 ON (pai2.`id_image` = i2.`id_image`)
|
||||
WHERE i2.`id_product` = p.`id_product` AND pai2.`id_product_attribute` = pa.`id_product_attribute`
|
||||
ORDER BY i2.`position`
|
||||
LIMIT 1),
|
||||
i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$this->id_lang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.(int)$this->id_lang.')
|
||||
'.Product::sqlStock('cp', 'cp').'
|
||||
WHERE cp.`id_cart` = '.(int)$this->id.'
|
||||
'.($id_product ? ' AND cp.`id_product` = '.(int)$id_product : '').'
|
||||
AND p.`id_product` IS NOT NULL
|
||||
GROUP BY unique_id
|
||||
ORDER BY cp.date_add ASC';
|
||||
$result = Db::getInstance()->ExecuteS($sql);
|
||||
// Reset the cache before the following return, or else an empty cart will add dozens of queries
|
||||
|
||||
@@ -632,9 +631,15 @@ class CartCore extends ObjectModel
|
||||
if ((int)$quantity < $minimalQuantity)
|
||||
return -1;
|
||||
|
||||
if (!Db::getInstance()->AutoExecute(_DB_PREFIX_.'cart_product', array('id_product' => (int)$id_product,
|
||||
'id_product_attribute' => (int)$id_product_attribute, 'id_cart' => (int)$this->id,
|
||||
'quantity' => (int)$quantity, 'date_add' => date('Y-m-d H:i:s')), 'INSERT'))
|
||||
$resultAdd = Db::getInstance()->AutoExecute(_DB_PREFIX_.'cart_product', array(
|
||||
'id_product' => (int)$id_product,
|
||||
'id_product_attribute' => (int)$id_product_attribute,
|
||||
'id_cart' => (int)$this->id,
|
||||
'id_shop' => $context->shop->getID(true),
|
||||
'quantity' => (int)$quantity,
|
||||
'date_add' => date('Y-m-d H:i:s')
|
||||
), 'INSERT');
|
||||
if (!$resultAdd)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1475,7 +1480,7 @@ class CartCore extends ObjectModel
|
||||
LEFT JOIN '._DB_PREFIX_.'orders o ON (c.`id_cart` = o.`id_cart`)
|
||||
WHERE c.`id_customer` = '.(int)($id_customer).'
|
||||
AND o.`id_cart` IS NULL
|
||||
'.Context::getContext()->shop->sqlRestriction(true, 'c').'
|
||||
'.Context::getContext()->shop->sqlRestriction(Shop::SHARE_ORDER, 'c').'
|
||||
ORDER BY c.`date_upd` DESC';
|
||||
if (!$id_cart = Db::getInstance()->getValue($sql))
|
||||
return false;
|
||||
|
||||
@@ -493,7 +493,7 @@ class CategoryCore extends ObjectModel
|
||||
{
|
||||
$sql = 'SELECT COUNT(cp.`id_product`) AS total
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->sqlAsso('product', 'p', true).'
|
||||
'.$context->shop->sqlAsso('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON p.`id_product` = cp.`id_product`
|
||||
WHERE cp.`id_category` = '.(int)($this->id).
|
||||
($active ? ' AND p.`active` = 1' : '').
|
||||
@@ -506,7 +506,7 @@ class CategoryCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'category_product` cp
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product`
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product` AND default_on = 1)
|
||||
'.$context->shop->sqlAsso('product', 'p', true).'
|
||||
'.$context->shop->sqlAsso('product', 'p').'
|
||||
'.Product::sqlStock('p', 'pa', false, $context).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.(int)$id_lang.$context->shop->sqlLang('cl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.$context->shop->sqlLang('pl').')
|
||||
|
||||
@@ -103,7 +103,7 @@ class ConnectionCore extends ObjectModel
|
||||
$sql = 'SELECT `id_connections` FROM `'._DB_PREFIX_.'connections`
|
||||
WHERE ip_address = '.ip2long(Tools::getRemoteAddr()).'
|
||||
AND DATE_ADD(`date_add`, INTERVAL 30 MINUTE) > \''.pSQL(date('Y-m-d H:i:00')).'\'
|
||||
'.$context->shop->sqlRestriction(true).'
|
||||
'.$context->shop->sqlRestriction(Shop::SHARE_CUSTOMER).'
|
||||
ORDER BY `date_add` DESC';
|
||||
if ($id_connections = Db::getInstance()->getValue($sql))
|
||||
{
|
||||
@@ -117,7 +117,7 @@ class ConnectionCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'connections`
|
||||
WHERE `id_guest` = '.(int)($cookie->id_guest).'
|
||||
AND DATE_ADD(`date_add`, INTERVAL 30 MINUTE) > \''.pSQL(date('Y-m-d H:i:00')).'\'
|
||||
'.$context->shop->sqlRestriction(true).'
|
||||
'.$context->shop->sqlRestriction(Shop::SHARE_CUSTOMER).'
|
||||
ORDER BY `date_add` DESC';
|
||||
$result = Db::getInstance()->getRow($sql);
|
||||
if (!$result['id_guest'] AND (int)($cookie->id_guest))
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ class ContactCore extends ObjectModel
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM `'._DB_PREFIX_.'contact` c
|
||||
'.$context->shop->sqlAsso('contact', 'c').'
|
||||
'.$context->shop->sqlAsso('contact', 'c', false).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'contact_lang` cl ON (c.`id_contact` = cl.`id_contact`)
|
||||
WHERE cl.`id_lang` = '.(int)$id_lang.'
|
||||
ORDER BY `name` ASC';
|
||||
|
||||
+6
-4
@@ -122,8 +122,10 @@ class CountryCore extends ObjectModel
|
||||
{
|
||||
if (!Validate::isBool($active))
|
||||
die(Tools::displayError());
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
$states = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
||||
SELECT s.*
|
||||
FROM `'._DB_PREFIX_.'state` s
|
||||
@@ -131,7 +133,7 @@ class CountryCore extends ObjectModel
|
||||
|
||||
$sql = 'SELECT cl.*,c.*, cl.`name` AS country, z.`name` AS zone
|
||||
FROM `'._DB_PREFIX_.'country` c
|
||||
'.$context->shop->sqlAsso('country', 'c').'
|
||||
'.$context->shop->sqlAsso('country', 'c', false).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country` AND cl.`id_lang` = '.(int)$id_lang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'zone` z ON z.`id_zone` = c.`id_zone`
|
||||
WHERE 1'
|
||||
@@ -296,7 +298,7 @@ class CountryCore extends ObjectModel
|
||||
|
||||
$sql = ' SELECT DISTINCT c.*, cl.*
|
||||
FROM `'._DB_PREFIX_.'country` c
|
||||
'.$context->shop->sqlAsso('country', 'c').'
|
||||
'.$context->shop->sqlAsso('country', 'c', false).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'state` s ON (s.`id_country` = c.`id_country`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country`)
|
||||
WHERE (c.`id_zone` = '.(int)$id_zone.' OR s.`id_zone` = '.(int)$id_zone.')
|
||||
|
||||
@@ -187,7 +187,7 @@ class CurrencyCore extends ObjectModel
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM `'._DB_PREFIX_.'currency` c
|
||||
'.$context->shop->sqlAsso('currency', 'c').'
|
||||
'.$context->shop->sqlAsso('currency', 'c', false).'
|
||||
WHERE `deleted` = 0'
|
||||
.($active == 1 ? ' AND c.`active` = 1' : '').'
|
||||
ORDER BY `name` ASC';
|
||||
|
||||
@@ -212,7 +212,7 @@ class CustomerCore extends ObjectModel
|
||||
$sql = 'SELECT `id_customer`, `email`, `firstname`, `lastname`
|
||||
FROM `'._DB_PREFIX_.'customer`
|
||||
WHERE 1
|
||||
'.$context->shop->sqlRestriction(true).'
|
||||
'.$context->shop->sqlRestriction(Shop::SHARE_CUSTOMER).'
|
||||
ORDER BY `id_customer` ASC';
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
|
||||
}
|
||||
@@ -236,7 +236,7 @@ class CustomerCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_ .'customer`
|
||||
WHERE `active` = 1
|
||||
AND `email` = \''.pSQL($email).'\'
|
||||
'.$context->shop->sqlRestriction(true).'
|
||||
'.$context->shop->sqlRestriction(Shop::SHARE_CUSTOMER).'
|
||||
'.(isset($passwd) ? 'AND `passwd` = \''.md5(_COOKIE_KEY_.$passwd).'\'' : '').'
|
||||
AND `deleted` = 0
|
||||
AND `is_guest` = 0';
|
||||
@@ -291,7 +291,7 @@ class CustomerCore extends ObjectModel
|
||||
$sql = 'SELECT `id_customer`
|
||||
FROM `'._DB_PREFIX_.'customer`
|
||||
WHERE `email` = \''.pSQL($email).'\'
|
||||
'.$context->shop->sqlRestriction(true).
|
||||
'.$context->shop->sqlRestriction(Shop::SHARE_CUSTOMER).
|
||||
($ignoreGuest ? 'AND `is_guest` = 0' : '');
|
||||
$result = Db::getInstance()->getRow($sql);
|
||||
|
||||
@@ -468,7 +468,7 @@ class CustomerCore extends ObjectModel
|
||||
OR `id_customer` LIKE \'%'.pSQL($query).'%\'
|
||||
OR `lastname` LIKE \'%'.pSQL($query).'%\'
|
||||
OR `firstname` LIKE \'%'.pSQL($query).'%\'
|
||||
)'.$context->shop->sqlRestriction(true);
|
||||
)'.$context->shop->sqlRestriction(Shop::SHARE_CUSTOMER);
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
|
||||
}
|
||||
|
||||
|
||||
@@ -518,8 +518,8 @@ class DiscountCore extends ObjectModel
|
||||
// @todo share datas on discount ? Utility of this function ?
|
||||
$sql = 'SELECT id_discount
|
||||
FROM '._DB_PREFIX_.'discount
|
||||
WHERE id_discount='.(int)$this->id
|
||||
.$shop->sqlRestriction(true);
|
||||
WHERE id_discount = '.(int)$this->id
|
||||
.$shop->sqlRestriction(false);
|
||||
return Db::getInstance()->getValue($sql);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +84,11 @@ class FrontControllerCore
|
||||
|
||||
$context = Context::getContext();
|
||||
|
||||
$protocol_link = (Configuration::get('PS_SSL_ENABLED') OR (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://';
|
||||
$protocol_content = ((isset($useSSL) AND $useSSL AND Configuration::get('PS_SSL_ENABLED')) OR (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://';
|
||||
$link = new Link($protocol_link, $protocol_content);
|
||||
$context->link = $link;
|
||||
|
||||
$this->id_current_shop = Context::getContext()->shop->getID();
|
||||
$this->id_current_group_shop = Context::getContext()->shop->getGroupID();
|
||||
|
||||
|
||||
@@ -32,14 +32,16 @@ class GroupShopCore extends ObjectModel
|
||||
{
|
||||
public $name;
|
||||
public $active;
|
||||
public $share_datas;
|
||||
public $share_customer;
|
||||
public $share_order;
|
||||
public $share_stock;
|
||||
public $deleted;
|
||||
|
||||
protected $fieldsSize = array('name' => 64);
|
||||
protected $fieldsValidate = array(
|
||||
'active' => 'isBool',
|
||||
'share_datas' => 'isBool',
|
||||
'share_customer' => 'isBool',
|
||||
'share_order' => 'isBool',
|
||||
'share_stock' => 'isBool',
|
||||
'name' => 'isGenericName',
|
||||
);
|
||||
@@ -63,8 +65,9 @@ class GroupShopCore extends ObjectModel
|
||||
parent::validateFields();
|
||||
|
||||
$fields['name'] = pSQL($this->name);
|
||||
$fields['share_datas'] = (int)$this->share_datas;
|
||||
$fields['share_customer'] = (int)$this->share_customer;
|
||||
$fields['share_stock'] = (int)$this->share_stock;
|
||||
$fields['share_order'] = ($fields['share_customer'] && $fields['share_stock']) ? (int)$this->share_order : false;
|
||||
$fields['active'] = (int)$this->active;
|
||||
$fields['deleted'] = (int)$this->deleted;
|
||||
return $fields;
|
||||
|
||||
+12
-6
@@ -68,16 +68,22 @@ class LinkCore
|
||||
* @param string $alias Friendly URL (only if $id_OBJ is the object)
|
||||
* @return string link
|
||||
*/
|
||||
public function getProductLink($id_product, $alias = NULL, $category = NULL, $ean13 = NULL, $id_lang = NULL)
|
||||
public function getProductLink($id_product, $alias = null, $category = null, $ean13 = null, $id_lang = null, $id_shop = null)
|
||||
{
|
||||
$url = _PS_BASE_URL_.__PS_BASE_URI__;
|
||||
|
||||
// @todo use specific method ?
|
||||
if ($id_shop && ($shop = Shop::getShop($id_shop)))
|
||||
$url = 'http://'.$shop['domain'].'/'.$shop['uri'];
|
||||
|
||||
if (is_object($id_product))
|
||||
return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink((int)$id_lang).((isset($id_product->category) AND !empty($id_product->category) AND $id_product->category != 'home') ? $id_product->category.'/' : '').(int)$id_product->id.'-'.$id_product->link_rewrite.($id_product->ean13 ? '-'.$id_product->ean13 : '').'.html') :
|
||||
(_PS_BASE_URL_.__PS_BASE_URI__.'index.php?controller=product&id_product='.(int)$id_product->id);
|
||||
return ($this->allow == 1)?($url.$this->getLangLink((int)$id_lang).((isset($id_product->category) AND !empty($id_product->category) AND $id_product->category != 'home') ? $id_product->category.'/' : '').(int)$id_product->id.'-'.$id_product->link_rewrite.($id_product->ean13 ? '-'.$id_product->ean13 : '').'.html') :
|
||||
($url.'index.php?controller=product&id_product='.(int)$id_product->id);
|
||||
elseif ($alias)
|
||||
return ($this->allow == 1)?(_PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink((int)$id_lang).(($category AND $category != 'home') ? ($category.'/') : '').(int)$id_product.'-'.$alias.($ean13 ? '-'.$ean13 : '').'.html') :
|
||||
(_PS_BASE_URL_.__PS_BASE_URI__.'index.php?controller=product&id_product='.(int)$id_product);
|
||||
return ($this->allow == 1)?($url.$this->getLangLink((int)$id_lang).(($category AND $category != 'home') ? ($category.'/') : '').(int)$id_product.'-'.$alias.($ean13 ? '-'.$ean13 : '').'.html') :
|
||||
($url.'index.php?controller=product&id_product='.(int)$id_product);
|
||||
else
|
||||
return _PS_BASE_URL_.__PS_BASE_URI__.'index.php?controller=product&id_product='.(int)$id_product;
|
||||
return $url.'index.php?controller=product&id_product='.(int)$id_product;
|
||||
}
|
||||
|
||||
public function getCategoryLink($id_category, $alias = NULL, $id_lang = NULL)
|
||||
|
||||
@@ -188,7 +188,7 @@ class ManufacturerCore extends ObjectModel
|
||||
if (!$id_lang)
|
||||
$id_lang = (int)Configuration::get('PS_LANG_DEFAULT');
|
||||
if (!$id_group_shop)
|
||||
$id_group_shop = Configuration::get('PS_GROUP_SHOP_DEFAULT');
|
||||
$id_group_shop = Shop::getGroupFromShop(Configuration::get('PS_SHOP_DEFAULT'));
|
||||
$sql = 'SELECT m.*, ml.`description`';
|
||||
$sql.= 'FROM `'._DB_PREFIX_.'manufacturer_group_shop` mgs
|
||||
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.id_manufacturer = mgs.id_manufacturer)
|
||||
@@ -293,7 +293,7 @@ class ManufacturerCore extends ObjectModel
|
||||
$sql = '
|
||||
SELECT p.`id_product`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->sqlAsso('product', 'p', true).'
|
||||
'.$context->shop->sqlAsso('product', 'p').'
|
||||
WHERE p.id_manufacturer = '.(int)($id_manufacturer)
|
||||
.($active ? ' AND p.`active` = 1' : '').'
|
||||
AND p.`id_product` IN (
|
||||
@@ -309,7 +309,7 @@ class ManufacturerCore extends ObjectModel
|
||||
$sql = 'SELECT p.*, pa.`id_product_attribute`, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, i.`id_image`, il.`legend`, m.`name` AS manufacturer_name, tl.`name` AS tax_name, t.`rate`, DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new,
|
||||
(p.`price` * ((100 + (t.`rate`))/100)) AS orderprice
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->sqlAsso('product', 'p', true).'
|
||||
'.$context->shop->sqlAsso('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product` AND default_on = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.$context->shop->sqlLang('pl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
|
||||
+4
-4
@@ -95,16 +95,16 @@ class MetaCore extends ObjectModel
|
||||
ORDER BY page ASC');
|
||||
}
|
||||
|
||||
static public function getMetasByIdLang($id_lang, Context $context = null)
|
||||
static public function getMetasByIdLang($id_lang, Shop $shop = null)
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM `'._DB_PREFIX_.'meta` m
|
||||
LEFT JOIN `'._DB_PREFIX_.'meta_lang` ml ON m.`id_meta` = ml.`id_meta`
|
||||
WHERE ml.`id_lang` = '.(int)$id_lang
|
||||
.$context->shop->sqlLang('ml').
|
||||
.$shop->sqlLang('ml').
|
||||
'ORDER BY page ASC';
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
|
||||
|
||||
|
||||
+14
-15
@@ -88,21 +88,20 @@ class PackCore extends Product
|
||||
|
||||
public static function getItemTable($id_product, $id_lang, $full = false)
|
||||
{
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
||||
SELECT p.*, pl.*, i.`id_image`, il.`legend`, t.`rate`, cl.`name` AS category_default, a.quantity AS pack_quantity
|
||||
FROM `'._DB_PREFIX_.'pack` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.id_product = a.id_product_item
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.id_product = pl.id_product AND pl.`id_lang` = '.(int)($id_lang).')
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)($id_lang).')
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.(int)($id_lang).')
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
|
||||
AND tr.`id_country` = '.(int)Context::getContext()->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_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = '.(int)($id_lang).')
|
||||
WHERE a.`id_product_pack` = '.(int)($id_product)
|
||||
);
|
||||
$sql = 'SELECT p.*, pl.*, i.`id_image`, il.`legend`, t.`rate`, cl.`name` AS category_default, a.quantity AS pack_quantity
|
||||
FROM `'._DB_PREFIX_.'pack` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.id_product = a.id_product_item
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.id_product = pl.id_product AND pl.`id_lang` = '.(int)$id_lang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.(int)$id_lang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
|
||||
AND tr.`id_country` = '.(int)Context::getContext()->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_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = '.(int)$id_lang.')
|
||||
WHERE a.`id_product_pack` = '.(int)$id_product;
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
|
||||
if (!$full)
|
||||
return $result;
|
||||
|
||||
|
||||
+12
-12
@@ -795,7 +795,7 @@ class ProductCore extends ObjectModel
|
||||
|
||||
$sql = 'SELECT p.*, pl.* , t.`rate` AS tax_rate, m.`name` AS manufacturer_name, s.`name` AS supplier_name
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->sqlAsso('product', 'p', true).'
|
||||
'.$context->shop->sqlAsso('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` '.$context->shop->sqlLang('pl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
|
||||
AND tr.`id_country` = '.(int)Context::getContext()->country->id.'
|
||||
@@ -822,7 +822,7 @@ class ProductCore extends ObjectModel
|
||||
|
||||
$sql = 'SELECT p.`id_product`, pl.`name`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->sqlAsso('product', 'p').'
|
||||
'.$context->shop->sqlAsso('product', 'p', false).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` '.$context->shop->sqlLang('pl').')
|
||||
WHERE pl.`id_lang` = '.(int)($id_lang).'
|
||||
ORDER BY pl.`name`';
|
||||
@@ -1368,7 +1368,7 @@ class ProductCore extends ObjectModel
|
||||
{
|
||||
$sql = 'SELECT COUNT(p.`id_product`) AS nb
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->sqlAsso('product', 'p', true).'
|
||||
'.$context->shop->sqlAsso('product', 'p').'
|
||||
WHERE `active` = 1
|
||||
AND DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0
|
||||
AND p.`id_product` IN (
|
||||
@@ -1384,7 +1384,7 @@ class ProductCore extends ObjectModel
|
||||
i.`id_image`, il.`legend`, t.`rate`, m.`name` AS manufacturer_name, DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new,
|
||||
(p.`price` * ((100 + (t.`rate`))/100)) AS orderprice, pa.id_product_attribute
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->sqlAsso('product', 'p', true).'
|
||||
'.$context->shop->sqlAsso('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.$context->shop->sqlLang('pl').')
|
||||
LEFT OUTER JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product` AND `default_on` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
@@ -1451,7 +1451,7 @@ class ProductCore extends ObjectModel
|
||||
// Please keep 2 distinct queries because RAND() is an awful way to achieve this result
|
||||
$sql = 'SELECT p.id_product
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->sqlAsso('product', 'p', true).'
|
||||
'.$context->shop->sqlAsso('product', 'p').'
|
||||
WHERE p.`active` = 1
|
||||
AND p.`id_product` IN ('.implode(', ', $ids_product).')
|
||||
AND p.`id_product` IN (
|
||||
@@ -1517,7 +1517,7 @@ class ProductCore extends ObjectModel
|
||||
{
|
||||
$sql = 'SELECT COUNT(DISTINCT p.`id_product`) AS nb
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->sqlAsso('product', 'p', true).'
|
||||
'.$context->shop->sqlAsso('product', 'p').'
|
||||
WHERE p.`active` = 1
|
||||
AND p.`show_price` = 1
|
||||
'.((!$beginning AND !$ending) ? ' AND p.`id_product` IN('.((is_array($ids_product) AND sizeof($ids_product)) ? implode(', ', $ids_product) : 0).')' : '').'
|
||||
@@ -1535,7 +1535,7 @@ class ProductCore extends ObjectModel
|
||||
pl.`name`, i.`id_image`, il.`legend`, t.`rate`, m.`name` AS manufacturer_name,
|
||||
DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->sqlAsso('product', 'p', true).'
|
||||
'.$context->shop->sqlAsso('product', 'p').'
|
||||
'.Product::sqlStock('p', 0, false, $context).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.$context->shop->sqlLang('pl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
@@ -1622,7 +1622,7 @@ class ProductCore extends ObjectModel
|
||||
|
||||
$sql = 'SELECT i.`cover`, i.`id_image`, il.`legend`
|
||||
FROM `'._DB_PREFIX_.'image` i
|
||||
'.$context->shop->sqlAsso('image', 'i', true).'
|
||||
'.$context->shop->sqlAsso('image', 'i').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
|
||||
WHERE i.`id_product` = '.(int)$this->id.'
|
||||
ORDER BY `position`';
|
||||
@@ -1641,7 +1641,7 @@ class ProductCore extends ObjectModel
|
||||
|
||||
$sql = 'SELECT i.`id_image`
|
||||
FROM `'._DB_PREFIX_.'image` i
|
||||
'.$context->shop->sqlAsso('image', 'i', true).'
|
||||
'.$context->shop->sqlAsso('image', 'i').'
|
||||
WHERE i.`id_product` = '.(int)($id_product).'
|
||||
AND i.`cover` = 1';
|
||||
return Db::getInstance()->getRow($sql);
|
||||
@@ -2342,7 +2342,7 @@ class ProductCore extends ObjectModel
|
||||
$sql = 'SELECT p.`id_product`, p.`reference`, pl.`name`
|
||||
FROM `'._DB_PREFIX_.'accessory`
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product`= `id_product_2`)
|
||||
'.$context->shop->sqlAsso('product', 'p', true).'
|
||||
'.$context->shop->sqlAsso('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.$context->shop->sqlLang('pl').')
|
||||
WHERE `id_product_1` = '.(int)$id_product;
|
||||
return Db::getInstance()->ExecuteS($sql);
|
||||
@@ -2364,7 +2364,7 @@ class ProductCore extends ObjectModel
|
||||
INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new
|
||||
FROM `'._DB_PREFIX_.'accessory`
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = `id_product_2`
|
||||
'.$context->shop->sqlAsso('product', 'p', true).'
|
||||
'.$context->shop->sqlAsso('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.$context->shop->sqlLang('pl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.(int)$id_lang.$context->shop->sqlLang('cl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
@@ -2511,7 +2511,7 @@ class ProductCore extends ObjectModel
|
||||
il.`legend`, m.`name` AS manufacturer_name, tl.`name` AS tax_name
|
||||
FROM `'._DB_PREFIX_.'category_product` cp
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product`
|
||||
'.$context->shop->sqlAsso('product', 'p', true).'
|
||||
'.$context->shop->sqlAsso('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.$context->shop->sqlLang('pl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
|
||||
AND tr.`id_country` = '.(int)Context::getContext()->country->id.'
|
||||
|
||||
@@ -51,7 +51,7 @@ class ProductSaleCore
|
||||
|
||||
$sql = 'SELECT COUNT(ps.`id_product`) AS nb
|
||||
FROM `'._DB_PREFIX_.'product_sale` ps
|
||||
'.$context->shop->sqlAsso('product', 'p').'
|
||||
'.$context->shop->sqlAsso('product', 'p', false).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = ps.`id_product`
|
||||
WHERE p.`active` = 1';
|
||||
return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
|
||||
@@ -85,7 +85,7 @@ class ProductSaleCore
|
||||
DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new
|
||||
FROM `'._DB_PREFIX_.'product_sale` ps
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON ps.`id_product` = p.`id_product`
|
||||
'.$context->shop->sqlAsso('product', 'p').'
|
||||
'.$context->shop->sqlAsso('product', 'p', false).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.$context->shop->sqlLang('pl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
|
||||
@@ -133,7 +133,7 @@ class ProductSaleCore
|
||||
$sql = 'SELECT p.id_product, pl.`link_rewrite`, pl.`name`, pl.`description_short`, i.`id_image`, il.`legend`, ps.`quantity` AS sales, p.`ean13`, p.`upc`, cl.`link_rewrite` AS category
|
||||
FROM `'._DB_PREFIX_.'product_sale` ps
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON ps.`id_product` = p.`id_product`
|
||||
'.$context->shop->sqlAsso('product', 'p', true).'
|
||||
'.$context->shop->sqlAsso('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.$context->shop->sqlLang('pl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
|
||||
|
||||
@@ -197,7 +197,7 @@ class ReferrerCore extends ObjectModel
|
||||
WHERE cu.date_add BETWEEN '.ModuleGraph::getDateBetween($employee).'
|
||||
'.$shop->sqlRestriction(false, 'rs').'
|
||||
'.$shop->sqlRestriction(false, 'c').'
|
||||
'.$shop->sqlRestriction(true, 'cu').'
|
||||
'.$shop->sqlRestriction(Shop::SHARE_CUSTOMER, 'cu').'
|
||||
AND cu.date_add > cs.date_add
|
||||
AND rc.id_referrer = '.(int)($this->id)
|
||||
.$where;
|
||||
@@ -232,7 +232,7 @@ class ReferrerCore extends ObjectModel
|
||||
WHERE oo.invoice_date BETWEEN '.ModuleGraph::getDateBetween($employee).'
|
||||
'.$shop->sqlRestriction(false, 'rs').'
|
||||
'.$shop->sqlRestriction(false, 'c').'
|
||||
'.$shop->sqlRestriction(true, 'oo').'
|
||||
'.$shop->sqlRestriction(Shop::SHARE_ORDER, 'oo').'
|
||||
AND oo.date_add > cs.date_add
|
||||
AND rc.id_referrer = '.(int)($this->id).'
|
||||
AND oo.valid = 1'
|
||||
@@ -249,7 +249,7 @@ class ReferrerCore extends ObjectModel
|
||||
$sql = 'SELECT COUNT(id_order) AS orders, SUM(total_paid_real / conversion_rate) AS sales
|
||||
FROM '._DB_PREFIX_.'orders
|
||||
WHERE id_order IN ('.implode($implode, ',').')
|
||||
'.$shop->sqlRestriction(true).'
|
||||
'.$shop->sqlRestriction(Shop::SHARE_ORDER).'
|
||||
AND valid = 1';
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
||||
}
|
||||
|
||||
+3
-3
@@ -210,7 +210,7 @@ class SearchCore
|
||||
INNER JOIN `'._DB_PREFIX_.'category_product` cp ON cp.`id_category` = cg.`id_category`
|
||||
INNER JOIN `'._DB_PREFIX_.'category` c ON cp.`id_category` = c.`id_category`
|
||||
INNER JOIN `'._DB_PREFIX_.'product` p ON cp.`id_product` = p.`id_product`
|
||||
'.$context->shop->sqlAsso('product', 'p').'
|
||||
'.$context->shop->sqlAsso('product', 'p', false).'
|
||||
WHERE c.`active` = 1
|
||||
AND p.`active` = 1
|
||||
AND indexed = 1
|
||||
@@ -553,7 +553,7 @@ class SearchCore
|
||||
{
|
||||
$sql = 'SELECT COUNT(DISTINCT pt.`id_product`) nb
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.$context->shop->sqlAsso('product', 'p', true).'
|
||||
'.$context->shop->sqlAsso('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_tag` pt ON (p.`id_product` = pt.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'tag` t ON (pt.`id_tag` = t.`id_tag` AND t.`id_lang` = '.(int)$id_lang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = p.`id_product`)
|
||||
@@ -570,7 +570,7 @@ class SearchCore
|
||||
DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 new
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.$context->shop->sqlLang('pl').')
|
||||
'.$context->shop->sqlAsso('product', 'p').'
|
||||
'.$context->shop->sqlAsso('product', 'p', false).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
|
||||
|
||||
+48
-30
@@ -94,6 +94,12 @@ class ShopCore extends ObjectModel
|
||||
const CONTEXT_SHOP = 1;
|
||||
const CONTEXT_GROUP = 2;
|
||||
const CONTEXT_ALL = 3;
|
||||
|
||||
/**
|
||||
* Some data can be shared between shops, like customers or orders
|
||||
*/
|
||||
const SHARE_CUSTOMER = 'share_customer';
|
||||
const SHARE_ORDER = 'share_order';
|
||||
|
||||
public function getFields()
|
||||
{
|
||||
@@ -332,10 +338,12 @@ class ShopCore extends ObjectModel
|
||||
if (self::$shops && !$refresh)
|
||||
return;
|
||||
|
||||
$sql = 'SELECT gs.id_group_shop, gs.name AS group_name, gs.share_datas, gs.share_stock, s.id_shop, s.name AS shop_name, s.id_theme, s.id_category, s.active
|
||||
$sql = 'SELECT gs.*, s.*, gs.name AS group_name, s.name AS shop_name, s.active, su.domain, su.domain_ssl, su.uri
|
||||
FROM '._DB_PREFIX_.'group_shop gs
|
||||
LEFT JOIN '._DB_PREFIX_.'shop s
|
||||
ON (s.id_group_shop = gs.id_group_shop)
|
||||
ON s.id_group_shop = gs.id_group_shop
|
||||
LEFT JOIN '._DB_PREFIX_.'shop_url su
|
||||
ON s.id_shop = su.id_shop AND su.main = 1
|
||||
WHERE s.deleted = 0
|
||||
AND gs.deleted = 0
|
||||
ORDER BY gs.name, s.name';
|
||||
@@ -347,7 +355,8 @@ class ShopCore extends ObjectModel
|
||||
self::$shops[$row['id_group_shop']] = array(
|
||||
'id' => $row['id_group_shop'],
|
||||
'name' => $row['group_name'],
|
||||
'share_datas' => $row['share_datas'],
|
||||
'share_customer' => $row['share_customer'],
|
||||
'share_order' => $row['share_order'],
|
||||
'share_stock' => $row['share_stock'],
|
||||
'shops' => array(),
|
||||
);
|
||||
@@ -358,6 +367,9 @@ class ShopCore extends ObjectModel
|
||||
'name' => $row['shop_name'],
|
||||
'id_theme' => $row['id_theme'],
|
||||
'id_category' => $row['id_category'],
|
||||
'domain' => $row['domain'],
|
||||
'domain_ssl' => $row['domain_ssl'],
|
||||
'uri' => $row['uri'],
|
||||
'active' => $row['active'],
|
||||
);
|
||||
}
|
||||
@@ -386,6 +398,21 @@ class ShopCore extends ObjectModel
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return some informations cached for one shop
|
||||
*
|
||||
* @param int $shopID
|
||||
* @return array
|
||||
*/
|
||||
public static function getShop($shopID)
|
||||
{
|
||||
Shop::cacheShops();
|
||||
foreach (self::$shops as $groupID => $groupData)
|
||||
if (array_key_exists($shopID, $groupData['shops']))
|
||||
return $groupData['shops'][$shopID];
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a shop ID from shop name
|
||||
@@ -427,16 +454,20 @@ class ShopCore extends ObjectModel
|
||||
}
|
||||
|
||||
/**
|
||||
* If the shop group has the option "share_datas" 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 $shopID
|
||||
* @param int $type Shop::SHARE_CUSTOMER or Shop::SHARE_ORDER
|
||||
* @return array
|
||||
*/
|
||||
public static function getSharedShops($shopID)
|
||||
public static function getSharedShops($shopID, $type)
|
||||
{
|
||||
if (!in_array($type, array(Shop::SHARE_CUSTOMER, Shop::SHARE_ORDER)))
|
||||
die('Wrong argument ($type) in Shop::getSharedShops() method');
|
||||
|
||||
Shop::cacheShops();
|
||||
foreach (self::$shops as $groupData)
|
||||
if (array_key_exists($shopID, $groupData['shops']) && $groupData['share_datas'])
|
||||
if (array_key_exists($shopID, $groupData['shops']) && $groupData[$type])
|
||||
return array_keys($groupData['shops']);
|
||||
return array($shopID);
|
||||
}
|
||||
@@ -444,7 +475,7 @@ class ShopCore extends ObjectModel
|
||||
/**
|
||||
* Get a list of ID concerned by the shop context (E.g. if context is shop group, get list of children shop ID)
|
||||
*
|
||||
* @param bool $share If true and if $shopID is set, list shops with share data too
|
||||
* @param int $share If false, dont check share datas from group. Else can take a Shop::SHARE_* constant value
|
||||
* @return array
|
||||
*/
|
||||
public function getListOfID($share = false)
|
||||
@@ -453,7 +484,7 @@ class ShopCore extends ObjectModel
|
||||
$shopGroupID = $this->getGroupID();
|
||||
|
||||
if ($shopID)
|
||||
$list = (!$share) ? array($shopID) : Shop::getSharedShops($shopID);
|
||||
$list = ($share) ? Shop::getSharedShops($shopID, $share) : array($shopID);
|
||||
else if ($shopGroupID)
|
||||
$list = Shop::getShops(true, $shopGroupID, true);
|
||||
else
|
||||
@@ -530,17 +561,7 @@ class ShopCore extends ObjectModel
|
||||
{
|
||||
return Shop::getContext('group');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of ID concerned by the shop context (E.g. if context is shop group, get list of children shop ID)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getListFromContext()
|
||||
{
|
||||
return Shop::getListOfID(Context::getContext());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check in which type of shop context we are
|
||||
*
|
||||
@@ -555,17 +576,14 @@ class ShopCore extends ObjectModel
|
||||
return Shop::CONTEXT_GROUP;
|
||||
return Shop::CONTEXT_ALL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if we are in "all" context
|
||||
* Add an sql restriction for shops fields
|
||||
*
|
||||
* @return bool
|
||||
* @param int $share If false, dont check share datas from group. Else can take a Shop::SHARE_* constant value
|
||||
* @param string $alias
|
||||
* @param string $type shop|group_shop
|
||||
*/
|
||||
public function inGlobalContext()
|
||||
{
|
||||
return $this->getContextType() == Shop::CONTEXT_ALL;
|
||||
}
|
||||
|
||||
public function sqlRestriction($share = false, $alias = null, $type = 'shop')
|
||||
{
|
||||
if ($type != 'shop' && $type != 'group_shop')
|
||||
@@ -588,7 +606,7 @@ class ShopCore extends ObjectModel
|
||||
else
|
||||
{
|
||||
if ($shopID || $shopGroupID)
|
||||
$restriction = ' AND '.$alias.'id_shop IN ('.implode(', ', Shop::getListOfID($shopID, $shopGroupID, $share)).')';
|
||||
$restriction = ' AND '.$alias.'id_shop IN ('.implode(', ', $this->getListOfID($share)).')';
|
||||
}
|
||||
|
||||
return $restriction;
|
||||
@@ -620,7 +638,7 @@ class ShopCore extends ObjectModel
|
||||
* @param Context $context
|
||||
* @return string
|
||||
*/
|
||||
public function sqlAsso($table, $alias, $innerJoin = false)
|
||||
public function sqlAsso($table, $alias, $innerJoin = true)
|
||||
{
|
||||
$tableAlias = ' asso_shop_'.$table;
|
||||
if (strpos($table, '.') !== false)
|
||||
@@ -632,7 +650,7 @@ class ShopCore extends ObjectModel
|
||||
|
||||
$sql = (($innerJoin) ? ' INNER' : ' LEFT').' JOIN '._DB_PREFIX_.$table.'_shop '.$tableAlias.'
|
||||
ON '.$tableAlias.'.id_'.$table.' = '.$alias.'.id_'.$table.'
|
||||
AND '.$tableAlias.'.id_shop IN('.implode(', ', Shop::getListOfID($this->getID(), $this->getGroupID())).') ';
|
||||
AND '.$tableAlias.'.id_shop IN('.implode(', ', $this->getListOfID()).') ';
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ class ShopUrlCore extends ObjectModel
|
||||
FROM '._DB_PREFIX_.'shop_url
|
||||
WHERE 1
|
||||
'.($id_shop ? ' AND id_shop = '.(int)$id_shop : '');
|
||||
return Db::getInstance()->ExecuteS();
|
||||
return Db::getInstance()->ExecuteS($sql);
|
||||
}
|
||||
|
||||
public function setMain()
|
||||
|
||||
+2
-2
@@ -1667,12 +1667,12 @@ class ToolsCore
|
||||
$tab['RewriteRule'][$domain]['content']['^'.ltrim($uri['uri'], '/').'content/category/([0-9]+)\-([a-zA-Z0-9-]*)'] = 'index.php?controller=cms&id_cms_category=$1&id_shop='.$uri['id_shop'].' [QSA,L]';
|
||||
|
||||
Language::loadLanguages();
|
||||
$default_meta = Meta::getMetasByIdLang((int)Configuration::get('PS_LANG_DEFAULT'), (int)$uri['id_shop']);
|
||||
$default_meta = Meta::getMetasByIdLang((int)Configuration::get('PS_LANG_DEFAULT'), new Shop($uri['id_shop']));
|
||||
|
||||
if ($multilang)
|
||||
foreach (Language::getLanguages() as $language)
|
||||
{
|
||||
foreach (Meta::getMetasByIdLang((int)$language['id_lang'], (int)$uri['id_shop']) as $key => $meta)
|
||||
foreach (Meta::getMetasByIdLang((int)$language['id_lang'], new Shop($uri['id_shop'])) as $key => $meta)
|
||||
if (!empty($meta['url_rewrite']) AND Validate::isLinkRewrite($meta['url_rewrite']))
|
||||
$tab['RewriteRule'][$domain]['content']['^'.ltrim($uri['uri'], '/').''.$language['iso_code'].'/'.$meta['url_rewrite'].'$'] = 'index.php?controller='.$meta['page'].'&isolang='.$language['iso_code'].'&id_shop='.$uri['id_shop'].' [QSA,L]';
|
||||
elseif (array_key_exists($key, $default_meta) && $default_meta[$key]['url_rewrite'] != '')
|
||||
|
||||
Reference in New Issue
Block a user