// fix product comparison

This commit is contained in:
tDidierjean
2011-08-11 08:39:52 +00:00
parent a39d1e520a
commit 8ca035aa55
6 changed files with 25 additions and 22 deletions
+13 -13
View File
@@ -47,27 +47,27 @@ class CompareControllerCore extends FrontController
{
if (Tools::getValue('action') == 'add')
{
if (isset(self::$cookie->id_customer))
if (isset($this->context->customer->id))
{
if(CompareProduct::getCustomerNumberProducts(self::$cookie->id_customer) < Configuration::get('PS_COMPARATOR_MAX_ITEM'))
CompareProduct::addCustomerCompareProduct((int)self::$cookie->id_customer, (int)Tools::getValue('id_product'));
if(CompareProduct::getCustomerNumberProducts($this->context->customer->id) < Configuration::get('PS_COMPARATOR_MAX_ITEM'))
CompareProduct::addCustomerCompareProduct((int)$this->context->customer->id, (int)Tools::getValue('id_product'));
else
die('0');
}
else
{
if ((isset(self::$cookie->id_guest) AND CompareProduct::getGuestNumberProducts(self::$cookie->id_guest) < Configuration::get('PS_COMPARATOR_MAX_ITEM')))
CompareProduct::addGuestCompareProduct((int)self::$cookie->id_guest, (int)Tools::getValue('id_product'));
if ((isset($this->context->customer->id_guest) AND CompareProduct::getGuestNumberProducts($this->context->customer->id_guest) < Configuration::get('PS_COMPARATOR_MAX_ITEM')))
CompareProduct::addGuestCompareProduct((int)$this->context->customer->id_guest, (int)Tools::getValue('id_product'));
else
die('0');
}
}
elseif (Tools::getValue('action') == 'remove')
{
if (isset(self::$cookie->id_customer))
CompareProduct::removeCustomerCompareProduct((int)self::$cookie->id_customer, (int)Tools::getValue('id_product'));
elseif (isset(self::$cookie->id_guest))
CompareProduct::removeGuestCompareProduct((int)self::$cookie->id_guest, (int)Tools::getValue('id_product'));
if (isset($this->context->customer->id))
CompareProduct::removeCustomerCompareProduct((int)$this->context->customer->id, (int)Tools::getValue('id_product'));
elseif (isset($this->context->customer->id_guest))
CompareProduct::removeGuestCompareProduct((int)$this->context->customer->id_guest, (int)Tools::getValue('id_product'));
else
die('0');
}
@@ -92,10 +92,10 @@ class CompareControllerCore extends FrontController
if ($product_list = Tools::getValue('compare_product_list') AND $postProducts = (isset($product_list) ? rtrim($product_list,'|') : ''))
$ids = array_unique(explode('|', $postProducts));
elseif (isset(self::$cookie->id_customer))
$ids = CompareProduct::getCustomerCompareProducts(self::$cookie->id_customer);
elseif(isset(self::$cookie->id_guest))
$ids = CompareProduct::getGuestCompareProducts(self::$cookie->id_guest);
elseif (isset($this->context->customer->id))
$ids = CompareProduct::getCustomerCompareProducts($this->context->customer->id);
elseif(isset($this->context->customer->id_guest))
$ids = CompareProduct::getGuestCompareProducts($this->context->customer->id_guest);
else
$ids = null;