protected static function _getProductIdByDate($beginning, $ending) { global $cookie, $cart; $id_group = $cookie->id_customer ? (int) Customer::getDefaultGroupId((int) $cookie->id_customer) : _PS_DEFAULT_CUSTOMER_GROUP_; $id_address = $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}; $ids = Address::getCountryAndState($id_address); $id_country = (int) ($ids['id_country'] ? $ids['id_country'] : Configuration::get('PS_COUNTRY_DEFAULT')); return SpecificPrice::getProductIdByDate((int) Shop::getCurrentShop(), (int) $cookie->id_currency, $id_country, $id_group, $beginning, $ending); }
protected function _getProductIdByDate($beginning, $ending, Context $context = null, $with_combination = false) { if (!$context) { $context = Context::getContext(); } $id_address = $context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}; $ids = Address::getCountryAndState($id_address); $id_country = (int) ($ids['id_country'] ? $ids['id_country'] : Configuration::get('PS_COUNTRY_DEFAULT')); return SpecificPrice::getProductIdByDate($context->shop->id, $context->currency->id, $id_country, $context->customer->id_default_group, $beginning, $ending, 0, $with_combination); }
private function _getPricesDropProductsIds() { $sqlGroups = ''; if (version_compare(_PS_VERSION_, '1.6.0.0', '>=') && Group::isFeatureActive() && version_compare(_PS_VERSION_, '1.6.0.0', '<')) { $currentGroups = FrontController::getCurrentCustomerGroups(); $sqlGroups = 'AND cg.`id_group` ' . (is_array($currentGroups) && sizeof($currentGroups) ? 'IN (' . implode(',', $currentGroups) . ')' : '= 1'); } $currentDate = date('Y-m-d H:i:s'); if (version_compare(_PS_VERSION_, '1.5.0.0', '<')) { global $cookie, $cart; $id_group = $cookie->id_customer ? (int) Customer::getDefaultGroupId((int) $cookie->id_customer) : _PS_DEFAULT_CUSTOMER_GROUP_; $id_address = $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}; $ids = Address::getCountryAndState($id_address); $id_country = (int) ($ids['id_country'] ? $ids['id_country'] : Configuration::get('PS_COUNTRY_DEFAULT')); $ids_product = SpecificPrice::getProductIdByDate((int) Shop::getCurrentShop(), (int) $cookie->id_currency, $id_country, $id_group, $currentDate, $currentDate); } else { $id_address = $this->_context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}; $ids = Address::getCountryAndState($id_address); $id_country = (int) ($ids['id_country'] ? $ids['id_country'] : Configuration::get('PS_COUNTRY_DEFAULT')); $ids_product = SpecificPrice::getProductIdByDate($this->_context->shop->id, $this->_context->currency->id, $id_country, $this->_context->customer->id_default_group, $currentDate, $currentDate, 0, false); } $tab_id_product = array(); foreach ($ids_product as $product) { if (is_array($product)) { $tab_id_product[] = (int) $product['id_product']; } else { $tab_id_product[] = (int) $product; } } Db::getInstance()->Execute('SET group_concat_max_len := @@max_allowed_packet'); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' SELECT GROUP_CONCAT(p.id_product) as pid_list FROM `' . _DB_PREFIX_ . 'product` p ' . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? Shop::addSqlAssociation('product', 'p') : '') . ' WHERE ' . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? 'product_shop' : 'p') . '.`active` = 1 AND ' . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? 'product_shop' : 'p') . '.`show_price` = 1 ' . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? ' AND product_shop.`visibility` IN ("both", "catalog") ' : '') . ' AND ' . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? 'product_shop' : 'p') . '.`id_product` IN (' . (is_array($tab_id_product) && count($tab_id_product) ? implode(', ', $tab_id_product) : 0) . ') AND p.`id_product` IN ( SELECT cp.`id_product` FROM `' . _DB_PREFIX_ . 'category_group` cg LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` ' . $sqlGroups . ' )'); if ($result && isset($result['pid_list']) && !empty($result['pid_list'])) { return explode(',', $result['pid_list']); } return array(0); }