Jump to content

Products-compare error


Recommended Posts

I am in the process of porting over my shop from oscommerce to prestashop. Everything seems to be working fine accept I cannot get the product compare to work.

 

I can select the products to compare, but when I press the compare button I am taken to https://fineartdelivered.com/products-compare It seems to be missing the "?compare_product_list=" that I see on my test version...As you can see the link displayed goes to an error (HTTP 500 Internal Server Error).

 

Also, when I go to the product page in the BO and delete a product I receive the same error page...although when I go back to the product page the product is erased.

 

Any help would be greatly appreciated. I also can not keep the site active for more than a couple of days as I do not want active traffic.

 

Thanks for the help.

Link to comment
Share on other sites

  • 7 months later...

Hello -

 

I just upgraded to PrestaShop 1.6.1.1 and am having the same issue with product comparison not working. The error I am receiving is:

 

Fatal error: Call to undefined method CompareController::getProduct() in /home/xxx/xxx/xxx/modules/socialsharing/socialsharing.php on line 161

 

Line 161 is:  $product = $this->context->controller->getProduct();

 

Could someone provide the fix for those of us who have upgraded to v1.6.1.1 as soon as possible?

 

Many thanks!

Link to comment
Share on other sites

I've managed to get it working on PrestaShop 1.6.1.1. The solution is ugly but it works. Comment everything after the addJs() and modify the return statement:

        public function hookDisplayHeader($params)
	{
                
		if (!isset($this->context->controller->php_self) || !in_array($this->context->controller->php_self, array('product', 'products-comparison')))
			return;

		$this->context->controller->addCss($this->_path.'css/socialsharing.css');
		$this->context->controller->addJS($this->_path.'js/socialsharing.js');
                /*
		$product = $this->context->controller->getProduct();

		if (!Validate::isLoadedObject($product)) {
			return;
		}

		if (!$this->isCached('socialsharing_header.tpl', $this->getCacheId('socialsharing_header|'.(isset($product->id) && $product->id ? (int)$product->id : ''))))
		{
			$this->context->smarty->assign(array(
				'price' => Tools::ps_round($product->getPrice(!Product::getTaxCalculationMethod((int)$this->context->cookie->id_customer), null), _PS_PRICE_COMPUTE_PRECISION_),
				'pretax_price' => Tools::ps_round($product->getPrice(false, null), _PS_PRICE_COMPUTE_PRECISION_),
				'weight' => $product->weight,
				'weight_unit' => Configuration::get('PS_WEIGHT_UNIT'),
				'cover' => isset($product->id) ? Product::getCover((int)$product->id) : '',
				'link_rewrite' => isset($product->link_rewrite) && $product->link_rewrite ? $product->link_rewrite : '',
			));
		}

		return $this->display(__FILE__, 'socialsharing_header.tpl', $this->getCacheId('socialsharing_header|'.(isset($product->id) && $product->id ? (int)$product->id : '')));
                */
                return $this->display(__FILE__, 'socialsharing_header.tpl', null);
	}
Edited by KCH (see edit history)
Link to comment
Share on other sites

A little better fix:

 

Search

$product = $this->context->controller->getProduct();

        if (!Validate::isLoadedObject($product)) {
            return;
        }

replace with:

// Exception are managed with Module::registerExceptions() but this is needed in case the merchant added new controllers afterwards
        if (!isset($this->context->controller->php_self) || $this->context->controller->php_self != 'product')
            return;

        $product = $this->context->controller->getProduct();
  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...

Yo lo estoy utilizando algo asi:

public function hookDisplayHeader($params)
	{
		if (!isset($this->context->controller->php_self) || !in_array($this->context->controller->php_self, array('product', 'products-comparison')))
			return;

		$this->context->controller->addCss($this->_path.'css/socialsharing.css');
		$this->context->controller->addJS($this->_path.'js/socialsharing.js');

		if(in_array($this->context->controller->php_self, array('product'))) $product = $this->context->controller->getProduct();

		if (!Validate::isLoadedObject($product)) {
			return;
		}
Edited by comprope (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 1 month later...

 

A little better fix:

 

Search

$product = $this->context->controller->getProduct();

        if (!Validate::isLoadedObject($product)) {
            return;
        }

replace with:

// Exception are managed with Module::registerExceptions() but this is needed in case the merchant added new controllers afterwards
        if (!isset($this->context->controller->php_self) || $this->context->controller->php_self != 'product')
            return;

        $product = $this->context->controller->getProduct();

 

I edited the following file: /public_html/modules/socialsharing/socialsharing.php with your code but the "Add to compare" is still not showing up.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...