public static function getNbProductsLess($ebay_profile, $option, $ebay_sync_last_product) { if (version_compare(_PS_VERSION_, '1.5', '>')) { $sql = ' SELECT COUNT(id_supplier) FROM( SELECT id_supplier FROM `' . _DB_PREFIX_ . 'product` AS p INNER JOIN `' . _DB_PREFIX_ . 'stock_available` AS s ON p.id_product = s.id_product'; if (version_compare(_PS_VERSION_, '1.5', '>')) { $sql .= ' INNER JOIN `' . _DB_PREFIX_ . 'product_shop` AS ps ON p.id_product = ps.id_product AND ps.id_shop = ' . (int) $ebay_profile->id_shop; } $sql .= ' WHERE s.`quantity` >0 AND p.`active` =1 AND p.`id_category_default` IN ( SELECT `id_category` FROM `' . _DB_PREFIX_ . 'ebay_category_configuration` WHERE `id_category` >0 AND `id_ebay_category` >0 AND `id_ebay_profile` = ' . (int) $ebay_profile->id . ($ebay_profile->getConfiguration('EBAY_SYNC_PRODUCTS_MODE') != 'A' ? ' AND `sync` = 1' : '') . ') ' . (Tools::getValue('option') == 1 ? EbaySynchronizer::_addSqlCheckProductInexistence('p') : '') . ' AND p.`id_product` >' . (int) $ebay_sync_last_product . ' AND p.`id_product` NOT IN (' . EbayProductConfiguration::getBlacklistedProductIdsQuery($ebay_profile->id) . ') ' . EbaySynchronizer::_addSqlRestrictionOnLang('s') . ' GROUP BY p.id_product )TableRequete'; } else { $sql = ' SELECT COUNT(`id_product`) FROM `' . _DB_PREFIX_ . 'product` AS p'; if (version_compare(_PS_VERSION_, '1.5', '>')) { $sql .= ' INNER JOIN `' . _DB_PREFIX_ . 'product_shop` AS ps ON p.id_product = ps.id_product AND ps.id_shop = ' . (int) $ebay_profile->id_shop; } $sql .= ' WHERE p.`quantity` > 0 AND p.`active` = 1 AND p.`id_category_default` IN ( SELECT `id_category` FROM `' . _DB_PREFIX_ . 'ebay_category_configuration` WHERE `id_category` > 0 AND `id_ebay_category` > 0 AND `id_ebay_profile` = ' . (int) $ebay_profile->id . ($ebay_profile->getConfiguration('EBAY_SYNC_PRODUCTS_MODE') != 'A' ? ' AND `sync` = 1' : '') . ' ) ' . (Tools::getValue('option') == 1 ? EbaySynchronizer::_addSqlCheckProductInexistence('p') : '') . ' AND p.`id_product` > ' . (int) $ebay_sync_last_product . ' AND p.`id_product` NOT IN (' . EbayProductConfiguration::getBlacklistedProductIdsQuery($ebay_profile->id) . ')'; } return Db::getInstance()->getValue($sql); }