// Improve multishop API

This commit is contained in:
rMalie
2012-02-23 15:54:10 +00:00
parent 6afc517815
commit dfdce557ee
6 changed files with 13 additions and 13 deletions
+5 -5
View File
@@ -703,7 +703,7 @@ class CategoryCore extends ObjectModel
if (is_null($id_lang))
$id_lang = $context->language->id;
if (!$shop)
if (Shop::isFeatureActive() && $context->shop() != Shop::CONTEXT_SHOP)
if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP)
$shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
else
$shop = $context->shop;
@@ -711,7 +711,7 @@ class CategoryCore extends ObjectModel
return new Category($shop->getCategory(), $id_lang);
$is_more_than_one_root_category = count(Category::getCategoriesWithoutParent()) > 1;
if ((!Shop::isFeatureActive() && $is_more_than_one_root_category) ||
Shop::isFeatureActive() && $is_more_than_one_root_category && $context->shop() != Shop::CONTEXT_SHOP)
Shop::isFeatureActive() && $is_more_than_one_root_category && Shop::getContext() != Shop::CONTEXT_SHOP)
$category = Category::getTopCategory($id_lang);
else
$category = new Category($shop->getCategory(), $id_lang);
@@ -975,17 +975,17 @@ class CategoryCore extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
ON (c.`id_category` = cl.`id_category`
AND `id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('cl').')';
if (Shop::isFeatureActive() && $context->shop() == Shop::CONTEXT_SHOP)
if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP)
$sql .= '
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs
ON (c.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.')';
$sql .= '
WHERE c.`id_category` = '.(int)$id_current;
if (Shop::isFeatureActive() && $context->shop() == Shop::CONTEXT_SHOP)
if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP)
$sql .= '
AND cs.`id_shop` = '.(int)$context->shop->id;
$root_category = Category::getRootCategory();
if (Shop::isFeatureActive() && $context->shop() == Shop::CONTEXT_SHOP &&
if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP &&
(!Tools::isSubmit('id_category') ||
(int)Tools::getValue('id_category') == (int)$root_category->id_category ||
(int)$root_category->id_category == (int)$context->shop->id_category))
+2 -2
View File
@@ -411,7 +411,7 @@ class StockAvailableCore extends ObjectModel
$stock_available->quantity = (int)$quantity;
// if we are in group_shop context
if ($context->shop() == Shop::CONTEXT_GROUP)
if (Shop::getContext() == Shop::CONTEXT_GROUP)
{
$group_shop = $context->shop->getGroup();
@@ -577,7 +577,7 @@ class StockAvailableCore extends ObjectModel
}
}
// else if we are in group context
else if ($context->shop() == Shop::CONTEXT_GROUP)
else if (Shop::getContext() == Shop::CONTEXT_GROUP)
{
if (is_object($sql))
$sql->where(pSQL($alias).'id_shop IN ('.implode(', ', Shop::getShops(true, $group_shop->id, true)).')');
@@ -81,7 +81,7 @@ class AdminCategoriesControllerCore extends AdminController
);
// if we are not in a shop context, we remove the position column
if ($this->context->shop() != Shop::CONTEXT_SHOP)
if (Shop::getContext() != Shop::CONTEXT_SHOP)
unset($this->fieldsDisplay['position']);
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected')));
@@ -98,7 +98,7 @@ class AdminCategoriesControllerCore extends AdminController
if (($id_category = Tools::getvalue('id_category')) && $this->action != 'select_delete')
$this->_category = new Category($id_category);
else
if (Shop::isFeatureActive() && $this->context->shop() == Shop::CONTEXT_SHOP)
if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP)
$this->_category = new Category($this->context->shop->id_category);
else if (count(Category::getCategoriesWithoutParent()) > 1)
$this->_category = Category::getTopCategory();
@@ -141,7 +141,7 @@ class AdminCategoriesControllerCore extends AdminController
$id_parent = $top_category->id;
else if ($is_multishop && $count_categories_without_parent == 1)
$id_parent = 2; //TODO need to get the ID category where category = Home
else if ($is_multishop && $count_categories_without_parent > 1 && $this->context->shop() != Shop::CONTEXT_SHOP)
else if ($is_multishop && $count_categories_without_parent > 1 && Shop::getContext() != Shop::CONTEXT_SHOP)
$id_parent = $top_category->id;
else
$id_parent = $this->context->shop->id_category;
@@ -3451,7 +3451,7 @@ class AdminProductsControllerCore extends AdminController
}
$show_quantities = true;
$shop_context = $this->context->shop();
$shop_context = Shop::getContext();
$group_shop = $this->context->shop->getGroup();
// if we are in all shops context, it's not possible to manage quantities at this level
+1 -1
View File
@@ -516,7 +516,7 @@ class AdminShopControllerCore extends AdminController
foreach ($children as $child)
$selected_cat[] = $child['id_category'];
}
if ($this->context->shop() == Shop::CONTEXT_SHOP && Tools::isSubmit('id_shop'))
if (Shop::getContext() == Shop::CONTEXT_SHOP && Tools::isSubmit('id_shop'))
$root_category = new Category($shop->id_category);
else
$root_category = new Category($id_root);
+1 -1
View File
@@ -1715,7 +1715,7 @@ class BlockLayered extends Module
// Translations are not automatic for the moment ;)
if (version_compare(_PS_VERSION_,'1.5','>'))
{
if ($this->context->shop() == Shop::CONTEXT_SHOP)
if (Shop::getContext() == Shop::CONTEXT_SHOP)
{
$root_category = Category::getRootCategory();
$root_category = array('id_category' => $root_category->id_category, 'name' => $root_category->name);