executeS('SELECT DISTINCT m.active FROM ' . _DB_PREFIX_ . 'manufacturer as m WHERE m.id_manufacturer = ' . $id_manufacturer); if (!empty($isActive) && isset($isActive[0]['active'])) { // Check if the 'active' field is equal to 1 return $isActive[0]['active'] == 1; } return false; } public static function getAssociatedSuppliers($id_product) { return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT DISTINCT ps.id_supplier FROM ' . _DB_PREFIX_ . 'product_supplier as ps WHERE ps.id_product = ' . $id_product); } /** * get all id_shop of private shops. * * @return array */ public static function getAssocShops() { $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT id_shop FROM ' . _DB_PREFIX_ . 'privateshoplite_shop'); $final = []; if (isset($result)) { foreach ($result as $res) { $final[] = $res['id_shop']; } } return $final; } /** * get customer email by id and token. * * @param string $token * * @return string */ public static function getCustomerEmail($id_customer, $token) { if (!$id_customer || empty($token)) { return false; } return Db::getInstance()->getValue('SELECT `email` FROM ' . _DB_PREFIX_ . 'customer c WHERE c.`secure_key` = \'' . pSQL($token) . '\' AND c.id_customer = ' . (int) $id_customer); } /** * get all shop customers. * * @return array */ public static function getAllCustomers() { $like = ''; $context = Context::getContext(); $search_n = ((int) Configuration::get('PRIVATESHOPLITE_FILTER_n', false, $context->shop->id_shop_group, $context->shop->id) <= 0) ? 10 : (int) Configuration::get('PRIVATESHOPLITE_FILTER_n', false, $context->shop->id_shop_group, $context->shop->id); $search_pos = (int) Configuration::get('PRIVATESHOPLITE_FILTER_pos', false, $context->shop->id_shop_group, $context->shop->id); $search_pos = ($search_pos <= 0) ? ' ORDER BY c.id_customer ASC ' : 'ORDER BY c.id_customer DESC '; $search_state = (int) Configuration::get('PRIVATESHOPLITE_FILTER_state', false, $context->shop->id_shop_group, $context->shop->id); $name = Configuration::get('PRIVATESHOPLITE_FILTER_name', false, $context->shop->id_shop_group, $context->shop->id); $whereClause = ' WHERE c.id_shop = ' . $context->shop->id . ' '; if (empty($name)) { $like = ''; } elseif ($name && ($search_state == 1 || $search_state == 2)) { $like = 'AND (c.firstname LIKE "%' . pSQL($name) . '%" OR c.lastname LIKE "%' . pSQL($name) . '%") '; } elseif ($name && $search_state <= 0) { $like = 'AND (c.firstname LIKE "%' . pSQL($name) . '%" OR c.lastname LIKE "%' . pSQL($name) . '%") '; } if ($search_state <= 0) { $search_state = ''; } elseif ($search_state == 1) { $search_state = 'AND c.active = 1 '; } elseif ($search_state == 2) { $search_state = 'AND c.active = 0 '; } $sql = 'SELECT c.*, CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) `customer`, gl.`name` AS `title`, (SELECT co.`date_add` FROM ' . _DB_PREFIX_ . 'guest g LEFT JOIN ' . _DB_PREFIX_ . 'connections co ON co.id_guest = g.id_guest WHERE g.id_customer = c.id_customer ORDER BY co.date_add DESC LIMIT 1 ) as connect FROM ' . _DB_PREFIX_ . 'customer c LEFT JOIN ' . _DB_PREFIX_ . 'gender_lang gl ON (c.id_gender = gl.id_gender AND gl.id_lang = ' . (int) Context::getContext()->language->id . ') ' . $whereClause . $search_state . $like . $search_pos . 'LIMIT ' . (int) $search_n; return Db::getInstance()->executeS($sql); } /** * Get all metas. * * @param int $idLang * * @return array|false|mysqli_result|PDOStatement|resource|null */ public static function getAllMeta($idLang) { return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT * FROM ' . _DB_PREFIX_ . 'meta m LEFT JOIN ' . _DB_PREFIX_ . 'meta_lang ml ON m.id_meta = ml.id_meta AND ml.id_lang = ' . (int) $idLang . ' ' . Shop::addSqlRestrictionOnLang('ml')); } }