// removing categories shop association

This commit is contained in:
vChabot
2011-12-21 16:05:42 +00:00
parent 6902ea817e
commit f67ad04205
3 changed files with 0 additions and 47 deletions
-1
View File
@@ -606,7 +606,6 @@ class AdminControllerCore extends Controller
$parent_id = (int)Tools::getValue('id_parent', 1);
$this->afterAdd($object);
$this->updateAssoShop($object->id);
// Save and stay on same form
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay'))
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.$object->id.'&conf=3&update'.$this->table.'&token='.$token;
-37
View File
@@ -1204,42 +1204,5 @@ class CategoryCore extends ObjectModel
return $categories;
}
/**
* @param $id_shop
* @return bool
*/
public function isParentCategoryAvailable($id_shop)
{
return (bool)Db::getInstance()->getValue('
SELECT c.`id_category`
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs
ON c.`id_category` = cs.`id_category`
WHERE cs.`id_shop` = '.(int)$id_shop.'
AND c.`id_parent` = '.(int)$this->id_parent);
}
/**
* Add association between shop and cateogries
* @param int $id_shop
* @return bool
*/
public function addShop($id_shop)
{
$sql = '';
if (!$id_shop)
{
foreach (Shop::getShops(true) as $shop)
$sql .= '('.(int)$this->id.', '.(int)$shop['id_shop'].'),';
// removing last comma to avoid SQL error
$sql = substr($sql, 0, strlen($sql) - 1);
} else
$sql .= '('.(int)$this->id.', '.(int)$id_shop.')';
return Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'category_shop` (`id_category`, `id_shop`) VALUES
'.$sql);
}
}
@@ -118,9 +118,6 @@ class AdminCategoriesControllerCore extends AdminController
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
{
// we add restriction for shop
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON a.`id_category` = cs.`id_category`';
$this->_where = ' AND cs.`id_shop` = '.(int)Context::getContext()->shop->getID(true);
parent::getList($id_lang, 'position', $order_way, $start, $limit, Context::getContext()->shop->getID(true));
// Check each row to see if there are combinations and get the correct action in consequence
@@ -433,12 +430,6 @@ class AdminCategoriesControllerCore extends AdminController
{
return strip_tags(stripslashes($description));
}
public function afterAdd($object)
{
// associate the category to the context shop
$object->addShop($this->context->shop->getID());
}
}