[-] FO : fixed mixed cache in different shops #PSCFV-3174
This commit is contained in:
@@ -1233,6 +1233,17 @@ class CategoryCore extends ObjectModel
|
||||
return false;
|
||||
return ($this->nleft >= $interval['nleft'] && $this->nright <= $interval['nright']);
|
||||
}
|
||||
|
||||
public static function inShopStatic($id_category, Shop $shop = null)
|
||||
{
|
||||
if (!$shop || !is_object($shop))
|
||||
$shop = Context::getContext()->shop;
|
||||
|
||||
if (!$interval = Category::getInterval($shop->getCategory()))
|
||||
return false;
|
||||
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('SELECT nleft, nright FROM `'._DB_PREFIX_.'category` WHERE id_category = '.(int)$id_category);
|
||||
return ($row['nleft'] >= $interval['nleft'] && $row['nright'] <= $interval['nright']);
|
||||
}
|
||||
|
||||
public function getChildrenWs()
|
||||
{
|
||||
|
||||
+9
-8
@@ -3978,18 +3978,19 @@ class ProductCore extends ObjectModel
|
||||
{
|
||||
if (!((int)$id_product > 0) || !is_array($categories) || empty($categories))
|
||||
return false;
|
||||
$sql = 'SELECT id_product FROM `'._DB_PREFIX_.'category_product` WHERE `id_product`='.(int)$id_product.' AND `id_category` IN(';
|
||||
$sql = 'SELECT id_product FROM `'._DB_PREFIX_.'category_product` WHERE `id_product` = '.(int)$id_product.' AND `id_category` IN (';
|
||||
foreach ($categories as $category)
|
||||
$sql .= (int)$category['id_category'].',';
|
||||
$sql = rtrim($sql, ',').')';
|
||||
|
||||
if (isset(self::$_incat[md5($sql)]))
|
||||
return self::$_incat[md5($sql)];
|
||||
|
||||
if (!Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql))
|
||||
return false;
|
||||
self::$_incat[md5($sql)] = (Db::getInstance(_PS_USE_SQL_SLAVE_)->NumRows() > 0 ? true : false);
|
||||
return self::$_incat[md5($sql)];
|
||||
$hash = md5($sql);
|
||||
if (!isset(self::$_incat[$hash]))
|
||||
{
|
||||
if (!Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql))
|
||||
return false;
|
||||
self::$_incat[$hash] = (Db::getInstance(_PS_USE_SQL_SLAVE_)->NumRows() > 0 ? true : false);
|
||||
}
|
||||
return self::$_incat[$hash];
|
||||
}
|
||||
|
||||
public function getNoPackPrice()
|
||||
|
||||
@@ -203,7 +203,9 @@ class BlockCategories extends Module
|
||||
}
|
||||
if (Tools::isSubmit('id_product'))
|
||||
{
|
||||
if (!isset($this->context->cookie->last_visited_category) || !Product::idIsOnCategoryId($id_product, array('0' => array('id_category' => $this->context->cookie->last_visited_category))))
|
||||
if (!isset($this->context->cookie->last_visited_category)
|
||||
|| !Product::idIsOnCategoryId($id_product, array('0' => array('id_category' => $this->context->cookie->last_visited_category)))
|
||||
|| !Category::inShopStatic($this->context->cookie->last_visited_category, $this->context->shop))
|
||||
{
|
||||
$product = new Product($id_product);
|
||||
if (isset($product) && Validate::isLoadedObject($product))
|
||||
|
||||
Reference in New Issue
Block a user