Jump to content

[SOLVED] Error when increase quantity in product without attributes


korsakov14

Recommended Posts

Hello,

I have a problem on my site with de PS version 1.7.5.1

When I increase or decrease the quantity of my product in product page, I recive this errror in logs:

 

Cita

*ERROR* v1.7.5.1 2019/03/13 - 16:47:31: Invalid parameter $idAttributes with value: "" at line 6246 in file classes/Product.php

The specific code where it fails is the following:

Cita

 

public static function getIdProductAttributeByIdAttributes($idProduct, $idAttributes, $findBest = false)
    {
        $idProduct = (int) $idProduct;

        if (!is_array($idAttributes) && is_numeric($idAttributes)) {
            $idAttributes = array((int) $idAttributes);
        }

        if (!is_array($idAttributes) || empty($idAttributes)) {
            throw new PrestaShopException(
                sprintf(
                    'Invalid parameter $idAttributes with value: "%s"',
                    print_r($idAttributes, true)
                )
            );
        }

 

 

These error only occurs in product without attributes. When add attributes works. And I debug mode also works. 😓

 

Does anyone know any clue as to why this error can be caused?

You can test it in https://www.turronartesano.com/es/turrones-de-jijona/turron-jijona-blando-300g

 

Thanks in advance, regards.

Edited by korsakov14 (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...
On 3/14/2019 at 1:23 PM, korsakov14 said:

Solved!!  it is a bug of the Pretty Urls plugin version 2.2.2 in PS 1.7.5.1.

Fixed after replacing the ProductController of the folder /overrides provided by plugin support. (Attached file).

I can already increase the quantity of my products without problems 🤗

ProductController.php.txt

its the file as the server. nothing change

  • Like 1
Link to comment
Share on other sites

Sorry, you're right.

This is the right one: 

<?php
/**
 * FMM PrettyURLs
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 *
 * @category  FMM Modules
 * @package   PrettyURLs
 * @author    FMM Modules
 * @copyright Copyright 2016 © Fmemodules All right reserved
 * @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*/

class ProductController extends ProductControllerCore
{
    public function init()
    {
        $link_rewrite     = Tools::safeOutput(urldecode(Tools::getValue('product_rewrite')));
        $prod_pattern = '/.*?\/([0-9]+)\-([_a-zA-Z0-9-\pL]*)\.html/';
        preg_match($prod_pattern, $_SERVER['REQUEST_URI'], $url_array);

        if (isset($url_array[2]) && $url_array[2] != '')
            $link_rewrite = $url_array[2];
        
        if ($link_rewrite)
        {
            $id_lang = $this->context->language->id;
            $id_shop = $this->context->shop->id;
            $sql = 'SELECT id_product
                    FROM '._DB_PREFIX_.'product_lang
                    WHERE link_rewrite = \''.pSQL($link_rewrite).'\' AND id_lang = '.(int)$id_lang.' AND id_shop = '.(int)$id_shop;
            $id_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
            if ($id_product > 0)
            {
                $_POST['id_product'] = $id_product;
                $_GET['product_rewrite'] = '';
            }
            else
            {
                $prod_pattern_sec = '/.*?\/([0-9]+)\-([_a-zA-Z0-9-\pL]*\-[0-9\pL]*)\.html/';
                preg_match($prod_pattern_sec, $_SERVER['REQUEST_URI'], $url_array_sec);
            
                if (isset($url_array_sec[2]) && $url_array_sec[2] != '')
                {
                    $segments = explode('-', $url_array_sec[2]);
                    array_pop($segments);
                    $link_rewrite = implode('-', $segments);
                }
                $sql = 'SELECT id_product
                    FROM '._DB_PREFIX_.'product_lang
                    WHERE link_rewrite = \''.pSQL($link_rewrite).'\' AND id_lang = '.(int)$id_lang.' AND id_shop = '.(int)$id_shop;
                $id_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
                if ($id_product > 0)
                {
                    $_POST['id_product'] = $id_product;
                    $_GET['product_rewrite'] = '';
                }
            }
        }
        parent::init();
    }
}

 

Link to comment
Share on other sites

  • 3 months later...

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...