• Hi,

    First of all, big up to aytechnet teams for this plugin !

    I am trying to use prestashop product integration with an article, however function getDefaultCountryId() used in prestashop-integration.php (line 521) is now deprecated with my current prestashop version (1.5.4.1), so the prestashop product integration doesn’t work.

    As described in Prestashop/classes/Country.php :
    @deprecated as of 1.5 use $context->country->id instead

    To solve this problem use you can replace getProducts function in prestashop-integration.php by, hope this helps someone.

    Regards,

    function getProducts( $id_lang, $ids, $get_products_properties = true ) {
    			$context = Context::getContext();
    			$sql = '
    			SELECT p.*, pa.<code>id_product_attribute</code>, pl.<code>description</code>, pl.<code>description_short</code>, pl.<code>available_now</code>, pl.<code>available_later</code>, pl.<code>link_rewrite</code>, pl.<code>meta_description</code>, pl.<code>meta_keywords</code>, pl.<code>meta_title</code>, pl.<code>name</code>, i.<code>id_image</code>, il.<code>legend</code>, m.<code>name</code> AS manufacturer_name, tl.<code>name</code> AS tax_name, t.<code>rate</code>, cl.<code>name</code> AS category_default, DATEDIFF(p.<code>date_add</code>, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new, (p.<code>price</code> * IF(t.<code>rate</code>,((100 + (t.<code>rate</code>))/100),1)) AS orderprice
    			FROM <code>'._DB_PREFIX_.'product</code> p
    			LEFT JOIN <code>'._DB_PREFIX_.'product_attribute</code> pa ON (p.<code>id_product</code> = pa.<code>id_product</code> AND default_on = 1)
    			LEFT JOIN <code>'._DB_PREFIX_.'category_lang</code> cl ON (p.<code>id_category_default</code> = cl.<code>id_category</code> AND cl.<code>id_lang</code> = '.(int)($id_lang).')
    			LEFT JOIN <code>'._DB_PREFIX_.'product_lang</code> pl ON (p.<code>id_product</code> = pl.<code>id_product</code> AND pl.<code>id_lang</code> = '.(int)($id_lang).')
    			LEFT JOIN <code>'._DB_PREFIX_.'image</code> i ON (i.<code>id_product</code> = p.<code>id_product</code> AND i.<code>cover</code> = 1)
    			LEFT JOIN <code>'._DB_PREFIX_.'image_lang</code> il ON (i.<code>id_image</code> = il.<code>id_image</code> AND il.<code>id_lang</code> = '.(int)($id_lang).')
    			LEFT JOIN <code>'._DB_PREFIX_.'tax_rule</code> tr ON (p.<code>id_tax_rules_group</code> = tr.<code>id_tax_rules_group</code>
    			                                           AND tr.<code>id_country</code> = '.(int)$context->country->id.'
    			                                           AND tr.<code>id_state</code> = 0)
    			LEFT JOIN <code>'._DB_PREFIX_.'tax</code> t ON (t.<code>id_tax</code> = tr.<code>id_tax</code>)
    			LEFT JOIN <code>'._DB_PREFIX_.'tax_lang</code> tl ON (t.<code>id_tax</code> = tl.<code>id_tax</code> AND tl.<code>id_lang</code> = '.(int)($id_lang).')
    			LEFT JOIN <code>'._DB_PREFIX_.'manufacturer</code> m ON m.<code>id_manufacturer</code> = p.<code>id_manufacturer</code>
    			WHERE p.<code>active</code> = 1 AND p.<code>id_product</code> IN ('.$ids.')';
    
    			$products = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
    			if ($get_products_properties)
    				$products = Product::getProductsProperties((int)($id_lang), $products);
    
    			return $products;
    		}

    http://wordpress.org/extend/plugins/prestashop-integration/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Fabien

    (@fmarrotpixel)

    function getProducts( $id_lang, $ids, $get_products_properties = true ) {
    $context = Context::getContext();
    $sql = ‘
    SELECT p.*, pa.id_product_attribute, pl.description, pl.description_short, pl.available_now, pl.available_later, pl.link_rewrite, pl.meta_description, pl.meta_keywords, pl.meta_title, pl.name, i.id_image, il.legend, m.name AS manufacturer_name, tl.name AS tax_name, t.rate, cl.name AS category_default, DATEDIFF(p.date_add, DATE_SUB(NOW(), INTERVAL ‘.(Validate::isUnsignedInt(Configuration::get(‘PS_NB_DAYS_NEW_PRODUCT’)) ? Configuration::get(‘PS_NB_DAYS_NEW_PRODUCT’) : 20).’ DAY)) > 0 AS new, (p.price * IF(t.rate,((100 + (t.rate))/100),1)) AS orderprice
    FROM '._DB_PREFIX_.'product p
    LEFT JOIN '._DB_PREFIX_.'product_attribute pa ON (p.id_product = pa.id_product AND default_on = 1)
    LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (p.id_category_default = cl.id_category AND cl.id_lang = ‘.(int)($id_lang).’)
    LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (p.id_product = pl.id_product AND pl.id_lang = ‘.(int)($id_lang).’)
    LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = p.id_product AND i.cover = 1)
    LEFT JOIN '._DB_PREFIX_.'image_lang il ON (i.id_image = il.id_image AND il.id_lang = ‘.(int)($id_lang).’)
    LEFT JOIN '._DB_PREFIX_.'tax_rule tr ON (p.id_tax_rules_group = tr.id_tax_rules_group
    AND tr.id_country = ‘.(int)$context->country->id.’
    AND tr.id_state = 0)
    LEFT JOIN '._DB_PREFIX_.'tax t ON (t.id_tax = tr.id_tax)
    LEFT JOIN '._DB_PREFIX_.'tax_lang tl ON (t.id_tax = tl.id_tax AND tl.id_lang = ‘.(int)($id_lang).’)
    LEFT JOIN '._DB_PREFIX_.'manufacturer m ON m.id_manufacturer = p.id_manufacturer
    WHERE p.active = 1 AND p.id_product IN (‘.$ids.’)’;

    $products = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
    if ($get_products_properties)
    $products = Product::getProductsProperties((int)($id_lang), $products);

    return $products;
    }

    Thread Starter Fabien

    (@fmarrotpixel)

    Mhhh not easy to share code….

    Anyway, add this before $sql (line 512) $context = Context::getContext();
    Then replace (int)Country::getDefaultCountryId() by (int)$context->country->id (line 521)

    Plugin Author aytechnet

    (@aytechnet)

    Hi Fabien,

    Thanks a lot for your sharing, the next version will get your patch.

    Kind Regards,
    François.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Prestashop function deprecated > getDefaultCountryId()’ is closed to new replies.