本文整理匯總了PHP中Group::isFeatureActive方法的典型用法代碼示例。如果您正苦於以下問題:PHP Group::isFeatureActive方法的具體用法?PHP Group::isFeatureActive怎麽用?PHP Group::isFeatureActive使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Group
的用法示例。
在下文中一共展示了Group::isFeatureActive方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getSubCategories
public static function getSubCategories($id_lang, $active = true, $id_category = 2, $p = 0, $n = 6)
{
$sql_groups_where = '';
$sql_groups_join = '';
if (Group::isFeatureActive()) {
$sql_groups_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cg.`id_category` = c.`id_category`)';
$groups = FrontController::getCurrentCustomerGroups();
$sql_groups_where = 'AND cg.`id_group` ' . (count($groups) ? 'IN (' . pSQL(implode(',', $groups)) . ')' : '=' . (int) Group::getCurrent()->id);
}
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.*, cl.id_lang, cl.name, cl.description, cl.link_rewrite, cl.meta_title, cl.meta_keywords, cl.meta_description
FROM `' . _DB_PREFIX_ . 'category` c
' . Shop::addSqlAssociation('category', 'c') . '
LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (c.`id_category` = cl.`id_category`
AND `id_lang` = ' . (int) $id_lang . ' ' . Shop::addSqlRestrictionOnLang('cl') . ')
' . $sql_groups_join . '
WHERE `id_parent` = ' . (int) $id_category . '
' . ($active ? 'AND `active` = 1' : '') . '
' . $sql_groups_where . '
GROUP BY c.`id_category`
ORDER BY `level_depth` ASC, category_shop.`position` ASC
LIMIT ' . (int) $p . ', ' . (int) $n);
foreach ($result as &$row) {
$row['id_image'] = Tools::file_exists_cache(_PS_CAT_IMG_DIR_ . $row['id_category'] . '.jpg') ? (int) $row['id_category'] : Language::getIsoById($id_lang) . '-default';
$row['legend'] = 'no picture';
}
return $result;
}
示例2: initFieldsetFeaturesDetachables
public function initFieldsetFeaturesDetachables()
{
$this->fields_form[2]['form'] = array('legend' => array('title' => $this->l('Optional features'), 'icon' => 'icon-puzzle-piece'), 'description' => $this->l('Some features can be disabled in order to improve performance.'), 'input' => array(array('type' => 'hidden', 'name' => 'features_detachables_up'), array('type' => 'switch', 'label' => $this->l('Combinations'), 'name' => 'combination', 'is_bool' => true, 'disabled' => Combination::isCurrentlyUsed(), 'values' => array(array('id' => 'combination_1', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'combination_0', 'value' => 0, 'label' => $this->l('No'))), 'hint' => $this->l('Choose "No" to disable Product Combinations.'), 'desc' => Combination::isCurrentlyUsed() ? $this->l('You cannot set this parameter to No when combinations are already used by some of your products') : null), array('type' => 'switch', 'label' => $this->l('Features'), 'name' => 'feature', 'is_bool' => true, 'values' => array(array('id' => 'feature_1', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'feature_0', 'value' => 0, 'label' => $this->l('No'))), 'hint' => $this->l('Choose "No" to disable Product Features.')), array('type' => 'switch', 'label' => $this->l('Customer Groups'), 'name' => 'customer_group', 'is_bool' => true, 'disabled' => Group::isCurrentlyUsed(), 'values' => array(array('id' => 'group_1', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'group_0', 'value' => 0, 'label' => $this->l('No'))), 'hint' => $this->l('Choose "No" to disable Customer Groups.'))), 'submit' => array('title' => $this->l('Save')));
$this->fields_value['combination'] = Combination::isFeatureActive();
$this->fields_value['feature'] = Feature::isFeatureActive();
$this->fields_value['customer_group'] = Group::isFeatureActive();
}
示例3: getCustomerGroups
public static function getCustomerGroups()
{
$groups = array();
if (version_compare(_PS_VERSION_, '1.5.0.0', '>=') && Group::isFeatureActive()) {
if (Validate::isLoadedObject(Context::getContext()->customer)) {
$groups = FrontController::getCurrentCustomerGroups();
} else {
$groups = array((int) Configuration::get('PS_UNIDENTIFIED_GROUP'));
}
} else {
if (version_compare(_PS_VERSION_, '1.4.0.2', '>=') && version_compare(_PS_VERSION_, '1.5.0.0', '<')) {
global $cookie;
$groups = Customer::getGroupsStatic((int) $cookie->id_customer);
} else {
if (version_compare(_PS_VERSION_, '1.4.0.2', '<') && version_compare(_PS_VERSION_, '1.2.5.0', '>=')) {
global $cookie;
$result = Db::getInstance()->ExecuteS('SELECT cg.`id_group` FROM ' . _DB_PREFIX_ . 'customer_group cg WHERE cg.`id_customer` = ' . (int) $cookie->id_customer);
if ($result && is_array($result)) {
foreach ($result as $group) {
$groups[] = (int) $group['id_group'];
}
}
}
}
}
sort($groups);
return $groups;
}
示例4: customGetNestedCategories
public function customGetNestedCategories($shop_id, $root_category = null, $id_lang = false, $active = false, $groups = null, $use_shop_restriction = true, $sql_filter = '', $sql_sort = '', $sql_limit = '')
{
if (isset($root_category) && !Validate::isInt($root_category)) {
die(Tools::displayError());
}
if (!Validate::isBool($active)) {
die(Tools::displayError());
}
if (isset($groups) && Group::isFeatureActive() && !is_array($groups)) {
$groups = (array) $groups;
}
$cache_id = 'Category::getNestedCategories_' . md5((int) $shop_id . (int) $root_category . (int) $id_lang . (int) $active . (int) $active . (isset($groups) && Group::isFeatureActive() ? implode('', $groups) : ''));
if (!Cache::isStored($cache_id)) {
$result = Db::getInstance()->executeS('
SELECT c.*, cl.*
FROM `' . _DB_PREFIX_ . 'category` c
INNER JOIN `' . _DB_PREFIX_ . 'category_shop` category_shop ON (category_shop.`id_category` = c.`id_category` AND category_shop.`id_shop` = "' . (int) $shop_id . '")
LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_shop` = "' . (int) $shop_id . '")
WHERE 1 ' . $sql_filter . ' ' . ($id_lang ? 'AND cl.`id_lang` = ' . (int) $id_lang : '') . '
' . ($active ? ' AND (c.`active` = 1 OR c.`is_root_category` = 1)' : '') . '
' . (isset($groups) && Group::isFeatureActive() ? ' AND cg.`id_group` IN (' . implode(',', $groups) . ')' : '') . '
' . (!$id_lang || isset($groups) && Group::isFeatureActive() ? ' GROUP BY c.`id_category`' : '') . '
' . ($sql_sort != '' ? $sql_sort : ' ORDER BY c.`level_depth` ASC') . '
' . ($sql_sort == '' && $use_shop_restriction ? ', category_shop.`position` ASC' : '') . '
' . ($sql_limit != '' ? $sql_limit : ''));
$categories = array();
$buff = array();
foreach ($result as $row) {
$current =& $buff[$row['id_category']];
$current = $row;
if ($row['id_parent'] == 0) {
$categories[$row['id_category']] =& $current;
} else {
$buff[$row['id_parent']]['children'][$row['id_category']] =& $current;
}
}
Cache::store($cache_id, $categories);
}
return Cache::retrieve($cache_id);
}
示例5: getProducts
public static function getProducts($id_supplier, $id_lang, $p, $n, $order_by = null, $order_way = null, $get_total = false, $active = true, $active_category = true)
{
/*
* EU-Legal
* get standard shipping time from database pl.*
*/
$context = Context::getContext();
$front = true;
if (!in_array($context->controller->controller_type, array('front', 'modulefront'))) {
$front = false;
}
if ($p < 1) {
$p = 1;
}
if (empty($order_by) || $order_by == 'position') {
$order_by = 'name';
}
if (empty($order_way)) {
$order_way = 'ASC';
}
if (!Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way)) {
die(Tools::displayError());
}
$sql_groups = '';
if (Group::isFeatureActive()) {
$groups = FrontController::getCurrentCustomerGroups();
$sql_groups = 'WHERE cg.`id_group` ' . (count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1');
}
/* Return only the number of products */
if ($get_total) {
return (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT COUNT(DISTINCT ps.`id_product`)
FROM `' . _DB_PREFIX_ . 'product_supplier` ps
JOIN `' . _DB_PREFIX_ . 'product` p ON (ps.`id_product`= p.`id_product`)
' . Shop::addSqlAssociation('product', 'p') . '
WHERE ps.`id_supplier` = ' . (int) $id_supplier . '
AND ps.id_product_attribute = 0
' . ($active ? ' AND product_shop.`active` = 1' : '') . '
' . ($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '') . '
AND p.`id_product` IN (
SELECT cp.`id_product`
FROM `' . _DB_PREFIX_ . 'category_product` cp
' . (Group::isFeatureActive() ? 'LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cp.`id_category` = cg.`id_category`)' : '') . '
' . ($active_category ? ' INNER JOIN `' . _DB_PREFIX_ . 'category` ca ON cp.`id_category` = ca.`id_category` AND ca.`active` = 1' : '') . '
' . $sql_groups . '
)');
}
$nb_days_new_product = Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20;
if (strpos('.', $order_by) > 0) {
$order_by = explode('.', $order_by);
$order_by = pSQL($order_by[0]) . '.`' . pSQL($order_by[1]) . '`';
}
$alias = '';
if (in_array($order_by, array('price', 'date_add', 'date_upd'))) {
$alias = 'product_shop.';
} elseif ($order_by == 'id_product') {
$alias = 'p.';
} elseif ($order_by == 'manufacturer_name') {
$order_by = 'name';
$alias = 'm.';
}
/*
* EU-Legal
* get standard shipping time from database pl.*
*/
$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock,
IFNULL(stock.quantity, 0) as quantity,
pl.`description`,
pl.`description_short`,
pl.`link_rewrite`,
pl.`meta_description`,
pl.`meta_keywords`,
pl.`meta_title`,
pl.`name`,
pl.`delivery_now`, pl.`delivery_later`,
MAX(image_shop.`id_image`) id_image,
il.`legend`,
s.`name` AS supplier_name,
DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL ' . $nb_days_new_product . ' DAY)) > 0 AS new,
m.`name` AS manufacturer_name' . (Combination::isFeatureActive() ? ', MAX(product_attribute_shop.minimal_quantity) AS product_attribute_minimal_quantity' : '') . '
FROM `' . _DB_PREFIX_ . 'product` p
' . Shop::addSqlAssociation('product', 'p') . '
JOIN `' . _DB_PREFIX_ . 'product_supplier` ps ON (ps.id_product = p.id_product
AND ps.id_product_attribute = 0)
LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa
ON (p.`id_product` = pa.`id_product`)
' . (Combination::isFeatureActive() ? Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1') : '') . '
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product`
AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . ')
LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product`)' . Shop::addSqlAssociation('image', 'i', false, 'image_shop.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_ . 'supplier` s ON s.`id_supplier` = p.`id_supplier`
LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
' . Product::sqlStock('p', 0);
if (Group::isFeatureActive() || $active_category) {
$sql .= 'JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (p.id_product = cp.id_product)';
if (Group::isFeatureActive()) {
$sql .= 'JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cp.`id_category` = cg.`id_category` AND cg.`id_group` ' . (count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1') . ')';
}
//.........這裏部分代碼省略.........
示例6: getNestedCategories
public static function getNestedCategories($images, $root_category = null, $id_lang = false, $active = true, $groups = null, $use_shop_restriction = true, $sql_filter = '', $sql_sort = '', $sql_limit = '')
{
$protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://';
$url = Tools::htmlentitiesutf8($protocol . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__);
$themeName = Context::getContext()->shop->getTheme();
$image_path = 'themes/' . $themeName . '/img/icontab/';
if (isset($root_category) && !Validate::isInt($root_category)) {
die(Tools::displayError());
}
if (!Validate::isBool($active)) {
die(Tools::displayError());
}
if (isset($groups) && Group::isFeatureActive() && !is_array($groups)) {
$groups = (array) $groups;
}
$cache_id = 'Category::getNestedCategories_' . md5((int) $root_category . (int) $id_lang . (int) $active . (int) $active . (isset($groups) && Group::isFeatureActive() ? implode('', $groups) : ''));
if (!Cache::isStored($cache_id)) {
$result = Db::getInstance()->executeS('
SELECT c.*, cl.*
FROM `' . _DB_PREFIX_ . 'category` c
' . ($use_shop_restriction ? Shop::addSqlAssociation('category', 'c') : '') . '
LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON c.`id_category` = cl.`id_category`' . Shop::addSqlRestrictionOnLang('cl') . '
' . (isset($groups) && Group::isFeatureActive() ? 'LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON c.`id_category` = cg.`id_category`' : '') . '
' . (isset($root_category) ? 'RIGHT JOIN `' . _DB_PREFIX_ . 'category` c2 ON c2.`id_category` = ' . (int) $root_category . ' AND c.`nleft` >= c2.`nleft` AND c.`nright` <= c2.`nright`' : '') . '
WHERE 1 ' . $sql_filter . ' ' . ($id_lang ? 'AND `id_lang` = ' . (int) $id_lang : '') . '
' . ($active ? ' AND c.`active` = 1' : '') . '
' . (isset($groups) && Group::isFeatureActive() ? ' AND cg.`id_group` IN (' . implode(',', $groups) . ')' : '') . '
' . (!$id_lang || isset($groups) && Group::isFeatureActive() ? ' GROUP BY c.`id_category`' : '') . '
' . ($sql_sort != '' ? $sql_sort : ' ORDER BY c.`level_depth` ASC') . '
' . ($sql_sort == '' && $use_shop_restriction ? ', category_shop.`position` ASC' : '') . '
' . ($sql_limit != '' ? $sql_limit : ''));
$categories = array();
$buff = array();
if (!isset($root_category)) {
$root_category = 1;
}
foreach ($result as $row) {
//add image to a category
if (array_key_exists($row['id_category'], $images)) {
# validate module
$row['image'] = $url . $image_path . $images[$row['id_category']];
}
$row['id_image'] = $row['id_category'] && file_exists(_PS_CAT_IMG_DIR_ . (int) $row['id_category'] . '.jpg') ? (int) $row['id_category'] : false;
$current =& $buff[$row['id_category']];
$current = $row;
if ($row['id_category'] == $root_category) {
# validate module
$categories[$row['id_category']] =& $current;
} else {
# validate module
$buff[$row['id_parent']]['children'][$row['id_category']] =& $current;
}
}
Cache::store($cache_id, $categories);
}
return Cache::retrieve($cache_id);
}
示例7: getFilterBlock
//.........這裏部分代碼省略.........
LEFT JOIN ' . _DB_PREFIX_ . 'layered_indexable_feature_value_lang_value lifvl
ON (lifvl.id_feature_value = fp.id_feature_value AND lifvl.id_lang = ' . $id_lang . ') ';
$sql_query['where'] = 'WHERE ' . $alias . '.`active` = 1 AND ' . $alias . '.`visibility` IN ("both", "catalog")
AND fp.id_feature = ' . (int) $filter['id_value'] . '
AND p.id_product IN (
SELECT id_product
FROM ' . _DB_PREFIX_ . 'category_product cp
INNER JOIN ' . _DB_PREFIX_ . 'category c ON (c.id_category = cp.id_category AND
' . (Configuration::get('PS_LAYERED_FULL_TREE') ? 'c.nleft >= ' . (int) $parent->nleft . '
AND c.nright <= ' . (int) $parent->nright : 'c.id_category = ' . (int) $id_parent) . '
AND c.active = 1)) ';
$sql_query['group'] = 'GROUP BY fv.id_feature_value';
if (!Configuration::get('PS_LAYERED_HIDE_0_VALUES')) {
$sql_query['second_query'] = '
SELECT fl.name feature_name, fp.id_feature, fv.id_feature_value, fvl.value,
0 nbr,
lifl.url_name name_url_name, lifl.meta_title name_meta_title, lifvl.url_name value_url_name, lifvl.meta_title value_meta_title
FROM ' . _DB_PREFIX_ . 'feature_product fp' . Shop::addSqlAssociation('product', 'fp') . '
INNER JOIN ' . _DB_PREFIX_ . 'product p ON (p.id_product = fp.id_product)
LEFT JOIN ' . _DB_PREFIX_ . 'feature_lang fl ON (fl.id_feature = fp.id_feature AND fl.id_lang = ' . (int) $id_lang . ')
INNER JOIN ' . _DB_PREFIX_ . 'feature_value fv ON (fv.id_feature_value = fp.id_feature_value AND (fv.custom IS NULL OR fv.custom = 0))
LEFT JOIN ' . _DB_PREFIX_ . 'feature_value_lang fvl ON (fvl.id_feature_value = fp.id_feature_value AND fvl.id_lang = ' . (int) $id_lang . ')
LEFT JOIN ' . _DB_PREFIX_ . 'layered_indexable_feature_lang_value lifl
ON (lifl.id_feature = fp.id_feature AND lifl.id_lang = ' . (int) $id_lang . ')
LEFT JOIN ' . _DB_PREFIX_ . 'layered_indexable_feature_value_lang_value lifvl
ON (lifvl.id_feature_value = fp.id_feature_value AND lifvl.id_lang = ' . (int) $id_lang . ')
WHERE ' . $alias . '.`active` = 1 AND ' . $alias . '.`visibility` IN ("both", "catalog")
AND fp.id_feature = ' . (int) $filter['id_value'] . '
GROUP BY fv.id_feature_value';
}
break;
case 'category':
if (Group::isFeatureActive()) {
$this->user_groups = $this->context->customer->isLogged() ? $this->context->customer->getGroups() : array(Configuration::get('PS_UNIDENTIFIED_GROUP'));
}
$depth = Configuration::get('PS_LAYERED_FILTER_CATEGORY_DEPTH');
if ($depth === false) {
$depth = 1;
}
$sql_query['select'] = '
SELECT c.id_category, c.id_parent, cl.name, (SELECT count(DISTINCT p.id_product) # ';
$sql_query['from'] = '
FROM ' . _DB_PREFIX_ . 'category_product cp
LEFT JOIN ' . _DB_PREFIX_ . 'product p ON (p.id_product = cp.id_product) ';
$sql_query['where'] = '
WHERE cp.id_category = c.id_category
AND ' . $alias . '.active = 1 AND ' . $alias . '.`visibility` IN ("both", "catalog")';
$sql_query['group'] = ') count_products
FROM ' . _DB_PREFIX_ . 'category c
LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (cl.id_category = c.id_category AND cl.`id_shop` = ' . (int) Context::getContext()->shop->id . ' and cl.id_lang = ' . (int) $id_lang . ') ';
if (Group::isFeatureActive()) {
$sql_query['group'] .= 'RIGHT JOIN ' . _DB_PREFIX_ . 'category_group cg ON (cg.id_category = c.id_category AND cg.`id_group` IN (' . implode(', ', $this->user_groups) . ')) ';
}
$sql_query['group'] .= 'WHERE c.nleft > ' . (int) $parent->nleft . '
AND c.nright < ' . (int) $parent->nright . '
' . ($depth ? 'AND c.level_depth <= ' . ($parent->level_depth + (int) $depth) : '') . '
AND c.active = 1
GROUP BY c.id_category ORDER BY c.nleft, c.position';
}
foreach ($filters as $filter_tmp) {
$method_name = 'get' . ucfirst($filter_tmp['type']) . 'FilterSubQuery';
if (method_exists('BlockLayered', $method_name) && (!in_array($filter['type'], array('price', 'weight')) && $filter['type'] != $filter_tmp['type'] || $filter['type'] == $filter_tmp['type'])) {
if ($filter['type'] == $filter_tmp['type'] && $filter['id_value'] == $filter_tmp['id_value']) {
$sub_query_filter = self::$method_name(array(), true);
} else {
示例8: getMainTags
public static function getMainTags($id_lang, $nb = 10)
{
$sql_groups = '';
if (Group::isFeatureActive()) {
$groups = FrontController::getCurrentCustomerGroups();
$sql_groups = '
AND p.`id_product` IN (
SELECT cp.`id_product`
FROM `' . _DB_PREFIX_ . 'category_product` cp
LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cp.`id_category` = cg.`id_category`)
WHERE cg.`id_group` ' . (count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1') . '
)';
}
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT t.name, COUNT(pt.id_tag) AS times
FROM `' . _DB_PREFIX_ . 'product_tag` pt
LEFT JOIN `' . _DB_PREFIX_ . 'tag` t ON (t.id_tag = pt.id_tag)
LEFT JOIN `' . _DB_PREFIX_ . 'product` p ON (p.id_product = pt.id_product)
' . Shop::addSqlAssociation('product', 'p') . '
WHERE t.`id_lang` = ' . (int) $id_lang . '
AND product_shop.`active` = 1
' . $sql_groups . '
GROUP BY t.id_tag
ORDER BY times DESC
LIMIT ' . (int) $nb);
}
示例9: getOrderProducts
/**
* @param array $products_id an array of product ids
* @return array
*/
protected function getOrderProducts(array $products_id)
{
$q_orders = 'SELECT o.id_order
FROM ' . _DB_PREFIX_ . 'orders o
LEFT JOIN ' . _DB_PREFIX_ . 'order_detail od ON (od.id_order = o.id_order)
WHERE o.valid = 1 AND od.product_id IN (' . implode(',', $products_id) . ')';
$orders = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($q_orders);
$final_products_list = array();
if (count($orders) > 0) {
$list = '';
foreach ($orders as $order) {
$list .= (int) $order['id_order'] . ',';
}
$list = rtrim($list, ',');
$list_product_ids = join(',', $products_id);
if (Group::isFeatureActive()) {
$sql_groups_join = '
LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = product_shop.id_category_default
AND cp.id_product = product_shop.id_product)
LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cp.`id_category` = cg.`id_category`)';
$groups = FrontController::getCurrentCustomerGroups();
$sql_groups_where = 'AND cg.`id_group` ' . (count($groups) ? 'IN (' . implode(',', $groups) . ')' : '=' . (int) Group::getCurrent()->id);
}
$order_products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT DISTINCT od.product_id, pl.name, pl.description_short, pl.link_rewrite, p.reference, i.id_image, product_shop.show_price,
cl.link_rewrite category, p.ean13, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity
FROM ' . _DB_PREFIX_ . 'order_detail od
LEFT JOIN ' . _DB_PREFIX_ . 'product p ON (p.id_product = od.product_id)
' . Shop::addSqlAssociation('product', 'p') . (Combination::isFeatureActive() ? 'LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa
ON (p.`id_product` = pa.`id_product`)
' . Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1') . '
' . Product::sqlStock('p', 'product_attribute_shop', false, $this->context->shop) : Product::sqlStock('p', 'product', false, $this->context->shop)) . '
LEFT JOIN ' . _DB_PREFIX_ . 'product_lang pl ON (pl.id_product = od.product_id' . Shop::addSqlRestrictionOnLang('pl') . ')
LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (cl.id_category = product_shop.id_category_default' . Shop::addSqlRestrictionOnLang('cl') . ')
LEFT JOIN ' . _DB_PREFIX_ . 'image i ON (i.id_product = od.product_id)
' . (Group::isFeatureActive() ? $sql_groups_join : '') . '
WHERE od.id_order IN (' . $list . ')
AND pl.id_lang = ' . (int) $this->context->language->id . '
AND cl.id_lang = ' . (int) $this->context->language->id . '
AND od.product_id NOT IN (' . $list_product_ids . ')
AND i.cover = 1
AND product_shop.active = 1
' . (Group::isFeatureActive() ? $sql_groups_where : '') . '
ORDER BY RAND()
LIMIT ' . (int) Configuration::get('CROSSSELLING_NBR'));
$tax_calc = Product::getTaxCalculationMethod();
foreach ($order_products as &$order_product) {
$order_product['id_product'] = (int) $order_product['product_id'];
$order_product['image'] = $this->context->link->getImageLink($order_product['link_rewrite'], (int) $order_product['product_id'] . '-' . (int) $order_product['id_image'], ImageType::getFormatedName('home'));
$order_product['link'] = $this->context->link->getProductLink((int) $order_product['product_id'], $order_product['link_rewrite'], $order_product['category'], $order_product['ean13']);
if (Configuration::get('CROSSSELLING_DISPLAY_PRICE') && ($tax_calc == 0 || $tax_calc == 2)) {
$order_product['displayed_price'] = Product::getPriceStatic((int) $order_product['product_id'], true, null);
} elseif (Configuration::get('CROSSSELLING_DISPLAY_PRICE') && $tax_calc == 1) {
$order_product['displayed_price'] = Product::getPriceStatic((int) $order_product['product_id'], false, null);
}
$order_product['allow_oosp'] = Product::isAvailableWhenOutOfStock((int) $order_product['out_of_stock']);
if (!isset($final_products_list[$order_product['product_id'] . '-' . $order_product['id_image']])) {
$final_products_list[$order_product['product_id'] . '-' . $order_product['id_image']] = $order_product;
}
}
}
return $final_products_list;
}
示例10: getImagesByCategory
public static function getImagesByCategory($categories, $start, $limit, $id_lang, Context $context = null)
{
if (!$context) {
$context = Context::getContext();
}
$front = true;
if (!in_array($context->controller->controller_type, array('front', 'modulefront'))) {
$front = false;
}
if (Group::isFeatureActive()) {
$groups = FrontController::getCurrentCustomerGroups();
$sql_groups = 'AND cg.`id_group` ' . (count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1');
}
$sql = 'SELECT
i.`id_image`,
pl.`link_rewrite`
FROM
`' . _DB_PREFIX_ . 'image` i
INNER JOIN `' . _DB_PREFIX_ . 'image_lang` il ON(i.`id_image` = il.`id_image`)
INNER JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON(
i.`id_product` = pl.`id_product`)
INNER JOIN `' . _DB_PREFIX_ . 'image_shop` ish ON (i.`id_image` = ish.`id_image`)';
$sql .= 'WHERE
i.`id_product` IN ( SELECT cp.`id_product`
FROM `' . _DB_PREFIX_ . 'category_product` cp
' . (Group::isFeatureActive() ? 'INNER JOIN `' . _DB_PREFIX_ . 'category_group` cg ON cp.`id_category` = cg.`id_category`' : '') . '
INNER JOIN `' . _DB_PREFIX_ . 'category` c ON cp.`id_category` = c.`id_category`
INNER JOIN `' . _DB_PREFIX_ . 'product` p ON cp.`id_product` = p.`id_product`
' . Shop::addSqlAssociation('product', 'p', false) . '
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` ' . Shop::addSqlRestrictionOnLang('pl') . ')
WHERE c.`active` = 1
AND product_shop.`active` = 1
' . ($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '') . '
' . $sql_groups . ' AND cp.id_category in (' . $categories . ')' . ' AND pl.id_lang =' . $id_lang . ')
AND il.`id_lang` =' . $id_lang . ' AND pl.id_lang = ' . $id_lang . ' AND pl.id_shop = ' . $context->shop->id . ' AND ish.id_shop = ' . $context->shop->id . ' AND ish.cover = 1
ORDER BY
i.`position` ASC' . ($limit > 0 ? ' LIMIT ' . (int) $start . ',' . (int) $limit : '');
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
}
示例11: checkAccessStatic
public static function checkAccessStatic($id_product, $id_customer)
{
if (!Group::isFeatureActive()) {
return true;
}
$cache_id = 'Product::checkAccess_' . (int) $id_product . '-' . (int) $id_customer . (!$id_customer ? '-' . (int) Group::getCurrent()->id : '');
if (!Cache::isStored($cache_id)) {
if (!$id_customer) {
$result = (bool) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT ctg.`id_group`
FROM `' . _DB_PREFIX_ . 'category_product` cp
INNER JOIN `' . _DB_PREFIX_ . 'category_group` ctg ON (ctg.`id_category` = cp.`id_category`)
WHERE cp.`id_product` = ' . (int) $id_product . ' AND ctg.`id_group` = ' . (int) Group::getCurrent()->id);
} else {
$result = (bool) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT cg.`id_group`
FROM `' . _DB_PREFIX_ . 'category_product` cp
INNER JOIN `' . _DB_PREFIX_ . 'category_group` ctg ON (ctg.`id_category` = cp.`id_category`)
INNER JOIN `' . _DB_PREFIX_ . 'customer_group` cg ON (cg.`id_group` = ctg.`id_group`)
WHERE cp.`id_product` = ' . (int) $id_product . ' AND cg.`id_customer` = ' . (int) $id_customer);
}
Cache::store($cache_id, $result);
return $result;
}
return Cache::retrieve($cache_id);
}
示例12: getMainTags
public static function getMainTags($id_lang, $nb = 10)
{
$context = Context::getContext();
if (Group::isFeatureActive()) {
$groups = FrontController::getCurrentCustomerGroups();
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT t.name, counter AS times
FROM `' . _DB_PREFIX_ . 'tag_count` pt
LEFT JOIN `' . _DB_PREFIX_ . 'tag` t ON (t.id_tag = pt.id_tag)
WHERE pt.`id_group` ' . (count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1') . '
AND pt.`id_lang` = ' . (int) $id_lang . ' AND pt.`id_shop` = ' . (int) $context->shop->id . '
ORDER BY times DESC
LIMIT ' . (int) $nb);
} else {
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT t.name, counter AS times
FROM `' . _DB_PREFIX_ . 'tag_count` pt
LEFT JOIN `' . _DB_PREFIX_ . 'tag` t ON (t.id_tag = pt.id_tag)
WHERE pt.id_group = 0 AND pt.`id_lang` = ' . (int) $id_lang . ' AND pt.`id_shop` = ' . (int) $context->shop->id . '
ORDER BY times DESC
LIMIT ' . (int) $nb);
}
}
示例13: getCacheId
protected function getCacheId($name = null)
{
$cache_array = array();
$cache_array[] = $name !== null ? $name : $this->name;
if (Configuration::get('PS_SSL_ENABLED')) {
$cache_array[] = (int) Tools::usingSecureMode();
}
if (Shop::isFeatureActive()) {
$cache_array[] = (int) $this->context->shop->id_shop_url;
}
if (Group::isFeatureActive()) {
$cache_array[] = (int) Group::getCurrent()->id;
}
if (Language::isMultiLanguageActivated()) {
$cache_array[] = (int) $this->context->language->id;
}
if (Currency::isMultiCurrencyActivated()) {
$cache_array[] = (int) $this->context->currency->id;
}
$cache_array[] = (int) $this->context->country->id;
return implode('|', $cache_array);
}
示例14: getProducts_Special
public static function getProducts_Special($id_lang, $arrCategory = array(), $params = null, $total = false, $limit = 0, $offset = 0)
{
$currentDate = date('Y-m-d');
$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'));
$where = "";
if ($arrCategory) {
$catIds = implode(', ', $arrCategory);
}
if ($params) {
if ($params->displayOnly == 'condition-new') {
$where .= " AND p.condition = 'new'";
} elseif ($params->displayOnly == 'condition-used') {
$where .= " AND p.condition = 'used'";
} elseif ($params->displayOnly == 'condition-refurbished') {
$where .= " AND p.condition = 'refurbished'";
}
}
if (Group::isFeatureActive()) {
$groups = FrontController::getCurrentCustomerGroups();
$where .= '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 cp.id_category IN (' . $catIds . ') AND cg.`id_group` ' . (count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1') . '
)';
} else {
$where .= 'AND p.`id_product` IN (
SELECT cp.`id_product`
FROM `' . _DB_PREFIX_ . 'category_product` cp
WHERE cp.id_category IN (' . $catIds . '))';
}
if ($total == true) {
$sql = 'SELECT COUNT(p.id_product)
FROM (`' . _DB_PREFIX_ . 'product` p
INNER JOIN `' . _DB_PREFIX_ . 'specific_price` sp On p.id_product = sp.id_product)
' . Shop::addSqlAssociation('product', 'p', false) . '
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl
ON p.`id_product` = pl.`id_product`
AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . '
WHERE product_shop.`active` = 1
AND sp.`id_shop` IN(0, ' . (int) $context->shop->id . ')
AND sp.`id_currency` IN(0, ' . (int) $context->currency->id . ')
AND sp.`id_country` IN(0, ' . (int) $id_country . ')
AND sp.`id_group` IN(0, ' . (int) $context->customer->id_default_group . ')
AND sp.`id_customer` IN(0)
AND sp.`from_quantity` = 1
AND (sp.`from` = \'0000-00-00 00:00:00\' OR \'' . pSQL($currentDate) . '\' >= sp.`from`)
AND (sp.`to` = \'0000-00-00 00:00:00\' OR \'' . pSQL($currentDate) . '\' <= sp.`to`)
AND sp.`reduction` > 0
AND p.`visibility` != \'none\' ' . $where;
return DB::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
}
$interval = Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20;
$sql = 'SELECT DISTINCT p.*, product_shop.*,
pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
pl.`meta_keywords`, pl.`meta_title`, pl.`name`, pl.`available_now`, pl.`available_later`,
MAX(image_shop.`id_image`) id_image, DATEDIFF(p.`date_add`, DATE_SUB(NOW(),INTERVAL ' . $interval . ' DAY)) > 0 AS new
FROM (`' . _DB_PREFIX_ . 'product` p
INNER JOIN `' . _DB_PREFIX_ . 'specific_price` sp On p.id_product = sp.id_product)
' . Shop::addSqlAssociation('product', 'p', false) . '
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl
ON p.`id_product` = pl.`id_product`
AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . '
LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product`)' . Shop::addSqlAssociation('image', 'i', false, 'image_shop.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_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
LEFT JOIN `' . _DB_PREFIX_ . 'tax_rule` tr ON (product_shop.`id_tax_rules_group` = tr.`id_tax_rules_group`)
AND tr.`id_country` = ' . (int) Context::getContext()->country->id . '
AND tr.`id_state` = 0
LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON (t.`id_tax` = tr.`id_tax`)
' . Product::sqlStock('p') . '
WHERE product_shop.`active` = 1
AND sp.`id_shop` IN(0, ' . (int) $context->shop->id . ')
AND sp.`id_currency` IN(0, ' . (int) $context->currency->id . ')
AND sp.`id_country` IN(0, ' . (int) $id_country . ')
AND sp.`id_group` IN(0, ' . (int) $context->customer->id_default_group . ')
AND sp.`id_customer` IN(0)
AND sp.`from_quantity` = 1
AND (sp.`from` = \'0000-00-00 00:00:00\' OR \'' . pSQL($currentDate) . '\' >= sp.`from`)
AND (sp.`to` = \'0000-00-00 00:00:00\' OR \'' . pSQL($currentDate) . '\' <= sp.`to`)
AND sp.`reduction` > 0
AND p.`visibility` != \'none\' ' . $where . '
GROUP BY product_shop.id_product
ORDER BY sp.`reduction` DESC Limit ' . $offset . ', ' . $limit;
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if (!$result) {
return false;
}
return $result;
}
示例15: getProductsOrderView
function getProductsOrderView($id_lang, $arrCategory = array(), $params = null, $total = false, $short = true, $limit, $offset = 0, $getProperties = true)
{
$context = Context::getContext();
$order_by = 'date_add';
$order_way = 'DESC';
$where = "";
if ($arrCategory) {
$catIds = implode(', ', $arrCategory);
}
if ($params) {
$order_way = $params->orderType;
if ($params->displayOnly == 'condition-new') {
$where .= " AND p.condition = 'new'";
} elseif ($params->displayOnly == 'condition-used') {
$where .= " AND p.condition = 'used'";
} elseif ($params->displayOnly == 'condition-refurbished') {
$where .= " AND p.condition = 'refurbished'";
}
}
if (Group::isFeatureActive()) {
$groups = FrontController::getCurrentCustomerGroups();
$where .= '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 cp.id_category IN (' . $catIds . ') AND cg.`id_group` ' . (count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1') . '
)';
} else {
$where .= 'AND p.`id_product` IN (
SELECT cp.`id_product`
FROM `' . _DB_PREFIX_ . 'category_product` cp
WHERE cp.id_category IN (' . $catIds . '))';
}
if ($total == true) {
$sql = 'SELECT COUNT(p.id_product)
FROM `' . _DB_PREFIX_ . 'product` p
' . Shop::addSqlAssociation('product', 'p', false) . '
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl
ON p.`id_product` = pl.`id_product`
AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . '
WHERE product_shop.`active` = 1 AND p.`visibility` != \'none\' ' . $where;
return (int) DB::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
}
$sql = 'SELECT p.id_product, p.ean13, p.reference, p.id_category_default, p.on_sale, p.quantity, p.minimal_quantity, p.price, p.wholesale_price, p.quantity_discount, p.show_price, p.condition,
product_shop.on_sale, product_shop.id_category_default, product_shop.minimal_quantity, product_shop.price, product_shop.wholesale_price, product_shop.show_price, product_shop.condition, product_shop.indexed,
stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, MAX(product_attribute_shop.id_product_attribute) id_product_attribute, product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity,
pl.`available_later`, pl.`link_rewrite`, pl.`name`, MAX(image_shop.`id_image`) id_image,
DATEDIFF(product_shop.`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, product_shop.price AS orderprice';
$sql .= ' FROM `' . _DB_PREFIX_ . 'product` p
LEFT JOIN `' . _DB_PREFIX_ . 'groupcategory_product_view` AS gv
On gv.productId = p.id_product
' . Shop::addSqlAssociation('product', 'p') . '
LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa
ON (p.`id_product` = pa.`id_product`)
' . Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1') . '
' . Product::sqlStock('p', 'product_attribute_shop', false, $context->shop) . '
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl
ON (p.`id_product` = pl.`id_product`
AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . ')
LEFT JOIN `' . _DB_PREFIX_ . 'image` i
ON (i.`id_product` = p.`id_product`)' . Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1') . '
WHERE
product_shop.`id_shop` = ' . (int) $context->shop->id . '
AND product_shop.`active` = 1 AND product_shop.`visibility` IN ("both", "catalog") ' . $where . '
GROUP BY product_shop.id_product
ORDER BY gv.`total` DESC Limit ' . $offset . ', ' . $limit;
$result = DB::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if (!$result) {
return false;
}
if ($getProperties == false) {
return $result;
}
return Product::getProductsProperties($id_lang, $result);
}