Forum Replies Created

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

    (@fmarrotpixel)

    deltafactory I really much appreciate you code sharing !

    Wondferfull !

    it works perfectly !

    Thanks

    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)

    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;
    }

Viewing 3 replies - 1 through 3 (of 3 total)