本文整理汇总了PHP中Shop::addSqlRestrictionOnLang方法的典型用法代码示例。如果您正苦于以下问题:PHP Shop::addSqlRestrictionOnLang方法的具体用法?PHP Shop::addSqlRestrictionOnLang怎么用?PHP Shop::addSqlRestrictionOnLang使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shop
的用法示例。
在下文中一共展示了Shop::addSqlRestrictionOnLang方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getItems
/**
* Get product accessories
*
* @param integer $id_lang Language id
* @return array Product accessories
*/
public static function getItems($iIdProduct, $id_lang, $active = true, Context $context = null)
{
if (!$context) {
$context = Context::getContext();
}
$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.`available_now`, pl.`available_later`,
MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` as manufacturer_name, 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
FROM `' . _DB_PREFIX_ . 'now_ideas_or_tips`
LEFT JOIN `' . _DB_PREFIX_ . 'product` p ON p.`id_product` = `id_product_2`
' . Shop::addSqlAssociation('product', 'p') . '
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_ . 'category_lang` cl ON (
product_shop.`id_category_default` = cl.`id_category`
AND cl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('cl') . '
)
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 (p.`id_manufacturer`= m.`id_manufacturer`)
' . Product::sqlStock('p', 0) . '
WHERE `id_product_1` = ' . (int) $iIdProduct . ($active ? ' AND product_shop.`active` = 1 AND product_shop.`visibility` != \'none\'' : '') . '
GROUP BY product_shop.id_product';
if (!($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql))) {
return false;
}
foreach ($result as &$row) {
$row['id_product_attribute'] = Product::getDefaultAttribute((int) $row['id_product']);
}
return Product::getProductsProperties($id_lang, $result);
}
示例2: getProductName
/**
* Gets the name of a given product, in the given lang
* HAI : override method to record product name with sort
*
* @since 1.5.0
* @param int $id_product
* @param int $id_product_attribute Optional
* @param int $id_lang Optional
* @return string
*/
public static function getProductName($id_product, $id_product_attribute = null, $id_lang = null)
{
// use the lang in the context if $id_lang is not defined
if (!$id_lang) {
$id_lang = (int) Context::getContext()->language->id;
}
// creates the query object
$query = new DbQuery();
// selects different names, if it is a combination
if ($id_product_attribute) {
$query->select('IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(DISTINCT agl.`name`, \' - \', al.name ORDER BY agl.`name`, \' - \', al.name ASC SEPARATOR \', \')),pl.name) as name');
} else {
$query->select('DISTINCT pl.name as name');
}
// adds joins & where clauses for combinations
if ($id_product_attribute) {
$query->from('product_attribute', 'pa');
$query->join(Shop::addSqlAssociation('product_attribute', 'pa'));
$query->innerJoin('product_lang', 'pl', 'pl.id_product = pa.id_product AND pl.id_lang = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl'));
$query->leftJoin('product_attribute_combination', 'pac', 'pac.id_product_attribute = pa.id_product_attribute');
$query->leftJoin('attribute', 'atr', 'atr.id_attribute = pac.id_attribute');
$query->leftJoin('attribute_lang', 'al', 'al.id_attribute = atr.id_attribute AND al.id_lang = ' . (int) $id_lang);
$query->leftJoin('attribute_group_lang', 'agl', 'agl.id_attribute_group = atr.id_attribute_group AND agl.id_lang = ' . (int) $id_lang);
$query->where('pa.id_product = ' . (int) $id_product . ' AND pa.id_product_attribute = ' . (int) $id_product_attribute);
} else {
$query->from('product_lang', 'pl');
$query->where('pl.id_product = ' . (int) $id_product);
$query->where('pl.id_lang = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl'));
}
return Db::getInstance()->getValue($query);
}
示例3: renderList
public function renderList()
{
$this->_select = 'b.*';
$this->_join = 'INNER JOIN `' . _DB_PREFIX_ . 'carrier_lang` b ON a.id_carrier = b.id_carrier' . Shop::addSqlRestrictionOnLang('b') . ' AND b.id_lang = ' . $this->context->language->id . ' LEFT JOIN `' . _DB_PREFIX_ . 'carrier_tax_rules_group_shop` ctrgs ON (a.`id_carrier` = ctrgs.`id_carrier` AND ctrgs.id_shop=' . (int) $this->context->shop->id . ')';
$this->_use_found_rows = false;
return parent::renderList();
}
示例4: renderList
/**
* AdminController::renderList() override
* @see AdminController::renderList()
*/
public function renderList()
{
// removes toolbar btn
$this->toolbar_btn = array();
// overrides select
$this->_select = '
CONCAT(pl.name, \' \', GROUP_CONCAT(IFNULL(al.name, \'\'), \'\')) product_name,
CONCAT(a.employee_lastname, \' \', a.employee_firstname) as employee,
mrl.name as reason,
stock.reference as product_reference,
stock.ean13 as product_ean13,
stock.upc as product_upc,
w.id_currency as id_currency,
w.name as warehouse_name';
// overrides join
$this->_join = 'INNER JOIN ' . _DB_PREFIX_ . 'stock stock ON a.id_stock = stock.id_stock
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (
stock.id_product = pl.id_product
AND pl.id_lang = ' . (int) $this->context->language->id . Shop::addSqlRestrictionOnLang('pl') . '
)
LEFT JOIN `' . _DB_PREFIX_ . 'stock_mvt_reason_lang` mrl ON (
a.id_stock_mvt_reason = mrl.id_stock_mvt_reason
AND mrl.id_lang = ' . (int) $this->context->language->id . '
)
LEFT JOIN `' . _DB_PREFIX_ . 'warehouse` w ON (w.id_warehouse = stock.id_warehouse)
LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_combination` pac ON (pac.id_product_attribute = stock.id_product_attribute)
LEFT JOIN `' . _DB_PREFIX_ . 'attribute_lang` al ON (
al.id_attribute = pac.id_attribute
AND pac.id_product_attribute <> 0
AND al.id_lang = ' . (int) $this->context->language->id . '
)';
// overrides group
$this->_group = 'GROUP BY a.id_stock_mvt';
// overrides where depending on the warehouse
$id_warehouse = (int) $this->getCurrentWarehouseId();
if ($id_warehouse > 0) {
$this->_where = ' AND w.id_warehouse = ' . $id_warehouse;
self::$currentIndex .= '&id_warehouse=' . $id_warehouse;
}
// sets the current warehouse
$this->tpl_list_vars['current_warehouse'] = $this->getCurrentWarehouseId();
// sets the list of warehouses
$warehouses = Warehouse::getWarehouses(true);
array_unshift($warehouses, array('id_warehouse' => -1, 'name' => $this->l('All Warehouses')));
$this->tpl_list_vars['list_warehouses'] = $warehouses;
// sets toolbar
$this->initToolbar();
// renders list
$list = parent::renderList();
// if export requested
if (Tools::isSubmit('csv')) {
if (count($this->_list) > 0) {
$this->renderCSV();
die;
} else {
$this->displayWarning($this->l('There is nothing to export as a CSV.'));
}
}
return $list;
}
示例5: renderContent
public function renderContent($setting)
{
$t = array('product_id' => 0, 'image_height' => '320', 'image_width' => 300);
$setting = array_merge($t, $setting);
$id_lang = (int) $this->lang_id;
$id_product = $setting['product_id'];
$sql = 'SELECT p.*, product_shop.*, stock.`out_of_stock` out_of_stock, pl.`description`, pl.`description_short`,
pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`,
p.`ean13`, p.`upc`, MAX(image_shop.`id_image`) id_image, il.`legend`,
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
FROM `' . _DB_PREFIX_ . 'product` p
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . '
)
' . Shop::addSqlAssociation('product', 'p') . '
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 . ')
' . Product::sqlStock('p', 0) . '
WHERE p.id_product = ' . (int) $id_product . '
GROUP BY product_shop.id_product';
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (!$row) {
return false;
}
if (isset($row['id_product_attribute']) && $row['id_product_attribute']) {
$row['id_product_attribute'] = $row['id_product_attribute'];
}
$p = Product::getProductProperties($id_lang, $row);
$setting['product'] = $p;
$output = array('type' => 'product', 'data' => $setting);
return $output;
}
示例6: 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;
}
示例7: renderList
public function renderList()
{
$this->displayInformation(' <b>' . $this->l('How do I create a new carrier?') . '</b>
<br />
<ul>
<li>' . $this->l('Click "Add New."') . '<br /></li>
<li>' . $this->l('Fill in the fields and click "Save."') . '</li>
<li>' . $this->l('You need to set a price range -- or weight range -- for which the new carrier will be available.') . ' ' . $this->l('Under the "Shipping" menu, click either "Price ranges" or "Weight ranges.".') . '
</li>
<li>' . $this->l('Click "Add New."') . '</li>
<li>' . $this->l('Select the name of the carrier before defining the price or weight range.') . ' ' . $this->l('For example, the carrier can be made available for a weight range between 0 and 5lbs. Another carrier can have a range between 5 and 10lbs.') . '
</li>
<li>' . $this->l('When you\'re done, click "Save."') . '</li>
<li>' . $this->l('Click on the "Shipping" menu.') . '</li>
<li>' . $this->l('You need to set the fees that will be applied for this carrier.') . ' ' . $this->l('At the bottom on the page -- in the "Fees" section -- select the name of the carrier.') . '
</li>
<li>' . $this->l('For each zone, enter a price and then click "Save."') . '</li>
<li>' . $this->l('You\'re all set! The new carrier will now be displayed to customers.') . '</li>
</ul>');
$this->_select = 'b.*';
$this->_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'carrier_lang` b ON a.id_carrier = b.id_carrier' . Shop::addSqlRestrictionOnLang('b') . '
LEFT JOIN `' . _DB_PREFIX_ . 'carrier_tax_rules_group_shop` ctrgs ON (a.`id_carrier` = ctrgs.`id_carrier`
AND ctrgs.id_shop=' . (int) $this->context->shop->id . ')';
$this->_where = 'AND b.id_lang = ' . $this->context->language->id;
return parent::renderList();
}
示例8: loadRoutes
/**
* Load default routes group by languages
*/
protected function loadRoutes($id_shop = null)
{
$context = Context::getContext();
// Load custom routes from modules
$modules_routes = Hook::exec('moduleRoutes', array('id_shop' => $id_shop), null, true, false);
if (is_array($modules_routes) && count($modules_routes)) {
foreach ($modules_routes as $module_route) {
if (is_array($module_route) && count($module_route)) {
foreach ($module_route as $route => $route_details) {
if (array_key_exists('controller', $route_details) && array_key_exists('rule', $route_details) && array_key_exists('keywords', $route_details) && array_key_exists('params', $route_details)) {
if (!isset($this->default_routes[$route])) {
$this->default_routes[$route] = array();
$this->default_routes[$route] = array_merge($this->default_routes[$route], $route_details);
}
}
}
}
}
}
// Set default routes
//new edit by Ha!*!*y :: Select only active languages
foreach (Language::getLanguages(TRUE) as $lang) {
foreach ($this->default_routes as $id => $route) {
$this->addRoute($id, $route['rule'], $route['controller'], $lang['id_lang'], $route['keywords'], isset($route['params']) ? $route['params'] : array(), $id_shop);
}
}
if ($this->use_routes) {
// Get iso lang
$iso_lang = Tools::getValue('isolang');
$id_lang = $context->language->id;
if (!empty($iso_lang)) {
$id_lang = Language::getIdByIso($iso_lang);
}
// Load routes from meta table
$sql = 'SELECT m.page, ml.url_rewrite, ml.id_lang
FROM `' . _DB_PREFIX_ . 'meta` m
LEFT JOIN `' . _DB_PREFIX_ . 'meta_lang` ml ON (m.id_meta = ml.id_meta' . Shop::addSqlRestrictionOnLang('ml', $id_shop) . ')
ORDER BY LENGTH(ml.url_rewrite) DESC';
if ($results = Db::getInstance()->executeS($sql)) {
foreach ($results as $row) {
if ($row['url_rewrite']) {
$this->addRoute($row['page'], $row['url_rewrite'], $row['page'], $row['id_lang'], array(), array(), $id_shop);
}
}
}
// Set default empty route if no empty route (that's weird I know)
if (!$this->empty_route) {
$this->empty_route = array('routeID' => 'index', 'rule' => '', 'controller' => 'index');
}
// Load custom routes
foreach ($this->default_routes as $route_id => $route_data) {
if ($custom_route = Configuration::get('PS_ROUTE_' . $route_id, null, null, $id_shop)) {
foreach (Language::getLanguages() as $lang) {
$this->addRoute($route_id, $custom_route, $route_data['controller'], $lang['id_lang'], $route_data['keywords'], isset($route_data['params']) ? $route_data['params'] : array(), $id_shop);
}
}
}
}
}
示例9: getGroupReductions
public static function getGroupReductions($id_group, $id_lang)
{
$lang = $id_lang . Shop::addSqlRestrictionOnLang('cl');
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT gr.`id_group_reduction`, gr.`id_group`, gr.`id_category`, gr.`reduction`, cl.`name` AS category_name
FROM `' . _DB_PREFIX_ . 'group_reduction` gr
LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (cl.`id_category` = gr.`id_category` AND cl.`id_lang` = ' . (int) $lang . ')
WHERE `id_group` = ' . (int) $id_group);
}
示例10: getPath
/**
* Get the user's journey
*
* @param integer $id_category Category ID
* @param string $path Path end
* @param boolean $linkOntheLastItem Put or not a link on the current category
* @param string [optionnal] $categoryType defined what type of categories is used (products or cms)
*/
public static function getPath($id_category, $path = '', $link_on_the_item = false, $category_type = 'products', Context $context = null)
{
if (!$context) {
$context = Context::getContext();
}
$id_category = (int) $id_category;
if ($id_category == 1) {
return '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span class="navigation_end">' . $path . '</span></div>';
}
$pipe = Configuration::get('PS_NAVIGATION_PIPE');
if (empty($pipe)) {
$pipe = '>';
}
$full_path = '';
if ($category_type === 'products') {
$interval = Category::getInterval($id_category);
$id_root_category = $context->shop->getCategory();
$interval_root = Category::getInterval($id_root_category);
if ($interval) {
$sql = 'SELECT c.id_category, cl.name, cl.link_rewrite
FROM ' . _DB_PREFIX_ . 'category c
LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (cl.id_category = c.id_category' . Shop::addSqlRestrictionOnLang('cl') . ')
' . Shop::addSqlAssociation('category', 'c') . '
WHERE c.nleft <= ' . $interval['nleft'] . '
AND c.nright >= ' . $interval['nright'] . '
AND c.nleft >= ' . $interval_root['nleft'] . '
AND c.nright <= ' . $interval_root['nright'] . '
AND cl.id_lang = ' . (int) $context->language->id . '
AND c.active = 1
AND c.level_depth > ' . (int) $interval_root['level_depth'] . '
ORDER BY c.level_depth ASC';
$categories = Db::getInstance()->executeS($sql);
$n = 1;
$n_categories = count($categories);
foreach ($categories as $category) {
$full_path .= '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">' . ($n < $n_categories || $link_on_the_item ? '<a href="' . Tools::safeOutput($context->link->getCategoryLink((int) $category['id_category'], $category['link_rewrite'])) . '" title="' . htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8') . '" itemprop="url">' : '') . '<span itemprop="title">' . htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8') . '</span>' . ($n < $n_categories || $link_on_the_item ? '</a>' : '') . '</div>' . ($n++ != $n_categories || !empty($path) ? '<span class="navigation-pipe">' . $pipe . '</span>' : '');
}
return $full_path . $path;
}
} else {
if ($category_type === 'CMS') {
$category = new CMSCategory($id_category, $context->language->id);
if (!Validate::isLoadedObject($category)) {
die(Tools::displayError());
}
$category_link = $context->link->getCMSCategoryLink($category);
if ($path != $category->name) {
$full_path .= '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . Tools::safeOutput($category_link) . '" itemprop="url"><span itemprop="title">' . htmlentities($category->name, ENT_NOQUOTES, 'UTF-8') . '</span></a><span class="navigation-pipe">' . $pipe . '</span>' . $path;
} else {
$full_path = ($link_on_the_item ? '<a href="' . Tools::safeOutput($category_link) . '" itemprop="url">' : '') . '<span itemprop="title">' . htmlentities($path, ENT_NOQUOTES, 'UTF-8') . '</span>' . ($link_on_the_item ? '</a>' : '');
}
return Tools::getPath($category->id_parent, $full_path, $link_on_the_item, $category_type);
}
}
}
示例11: getProductLight
/**
* Get product width light information
*
* @param array $iIdProduct Product id
* @return array Product
*/
public static function getProductLight($iIdProduct)
{
$sql = 'SELECT p.`id_product`, p.`reference`, pl.`name`
FROM `' . _DB_PREFIX_ . 'product` p
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = ' . (int) Context::getContext()->language->id . Shop::addSqlRestrictionOnLang('pl') . '
)
WHERE p.`id_product` = ' . $iIdProduct;
return Db::getInstance()->getRow($sql);
}
示例12: hookRightColumn
public function hookRightColumn($params)
{
$productsViewed = isset($params['cookie']->viewed) && !empty($params['cookie']->viewed) ? array_slice(array_reverse(explode(',', $params['cookie']->viewed)), 0, Configuration::get('PRODUCTS_VIEWED_NBR')) : array();
if (count($productsViewed)) {
$defaultCover = Language::getIsoById($params['cookie']->id_lang) . '-default';
$productIds = implode(',', array_map('intval', $productsViewed));
$productsImages = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT MAX(image_shop.id_image) id_image, p.id_product, il.legend, product_shop.active, pl.name, pl.description_short, pl.link_rewrite, cl.link_rewrite AS category_rewrite
FROM ' . _DB_PREFIX_ . 'product p
' . Shop::addSqlAssociation('product', 'p') . '
LEFT JOIN ' . _DB_PREFIX_ . 'product_lang pl ON (pl.id_product = p.id_product' . 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 (il.id_image = image_shop.id_image AND il.id_lang = ' . (int) $params['cookie']->id_lang . ')
LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (cl.id_category = product_shop.id_category_default' . Shop::addSqlRestrictionOnLang('cl') . ')
WHERE p.id_product IN (' . $productIds . ')
AND pl.id_lang = ' . (int) $params['cookie']->id_lang . '
AND cl.id_lang = ' . (int) $params['cookie']->id_lang . '
GROUP BY product_shop.id_product');
$productsImagesArray = array();
foreach ($productsImages as $pi) {
$productsImagesArray[$pi['id_product']] = $pi;
}
$productsViewedObj = array();
foreach ($productsViewed as $productViewed) {
$obj = (object) 'Product';
if (!isset($productsImagesArray[$productViewed]) || !($obj->active = $productsImagesArray[$productViewed]['active'])) {
continue;
} else {
$obj->id = (int) $productsImagesArray[$productViewed]['id_product'];
$obj->id_image = (int) $productsImagesArray[$productViewed]['id_image'];
$obj->cover = (int) $productsImagesArray[$productViewed]['id_product'] . '-' . (int) $productsImagesArray[$productViewed]['id_image'];
$obj->legend = $productsImagesArray[$productViewed]['legend'];
$obj->name = $productsImagesArray[$productViewed]['name'];
$obj->description_short = $productsImagesArray[$productViewed]['description_short'];
$obj->link_rewrite = $productsImagesArray[$productViewed]['link_rewrite'];
$obj->category_rewrite = $productsImagesArray[$productViewed]['category_rewrite'];
// $obj is not a real product so it cannot be used as argument for getProductLink()
$obj->product_link = $this->context->link->getProductLink($obj->id, $obj->link_rewrite, $obj->category_rewrite);
if (!isset($obj->cover) || !$productsImagesArray[$productViewed]['id_image']) {
$obj->cover = $defaultCover;
$obj->legend = '';
}
$productsViewedObj[] = $obj;
}
}
if (!count($productsViewedObj)) {
return;
}
$this->smarty->assign(array('productsViewedObj' => $productsViewedObj, 'mediumSize' => Image::getSize('medium')));
return $this->display(__FILE__, 'blockviewed.tpl');
}
return;
}
示例13: getData
public function getData()
{
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$date_between = $this->getDate();
$array_date_between = explode(' AND ', $date_between);
$this->query = 'SELECT SQL_CALC_FOUND_ROWS p.reference, p.id_product, pl.name,
ROUND(AVG(od.product_price / o.conversion_rate), 2) as avgPriceSold,
IFNULL(stock.quantity, 0) as quantity,
IFNULL(SUM(od.product_quantity), 0) AS totalQuantitySold,
ROUND(IFNULL(IFNULL(SUM(od.product_quantity), 0) / (1 + LEAST(TO_DAYS(' . $array_date_between[1] . '), TO_DAYS(NOW())) - GREATEST(TO_DAYS(' . $array_date_between[0] . '), TO_DAYS(product_shop.date_add))), 0), 2) as averageQuantitySold,
ROUND(IFNULL(SUM((od.product_price * od.product_quantity) / o.conversion_rate), 0), 2) AS totalPriceSold,
(
SELECT IFNULL(SUM(pv.counter), 0)
FROM ' . _DB_PREFIX_ . 'page pa
LEFT JOIN ' . _DB_PREFIX_ . 'page_viewed pv ON pa.id_page = pv.id_page
LEFT JOIN ' . _DB_PREFIX_ . 'date_range dr ON pv.id_date_range = dr.id_date_range
WHERE pa.id_object = p.id_product AND pa.id_page_type = ' . (int) Page::getPageTypeByName('product') . '
AND dr.time_start BETWEEN ' . $date_between . '
AND dr.time_end BETWEEN ' . $date_between . '
) AS totalPageViewed,
product_shop.active
FROM ' . _DB_PREFIX_ . 'product p
' . Shop::addSqlAssociation('product', 'p') . '
LEFT JOIN ' . _DB_PREFIX_ . 'product_lang pl ON (p.id_product = pl.id_product AND pl.id_lang = ' . (int) $this->getLang() . ' ' . Shop::addSqlRestrictionOnLang('pl') . ')
LEFT JOIN ' . _DB_PREFIX_ . 'order_detail od ON od.product_id = p.id_product
LEFT JOIN ' . _DB_PREFIX_ . 'orders o ON od.id_order = o.id_order
' . Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o') . '
' . Product::sqlStock('p', 0) . '
WHERE o.valid = 1
AND o.invoice_date BETWEEN ' . $date_between . '
GROUP BY od.product_id';
if (Validate::IsName($this->_sort)) {
$this->query .= ' ORDER BY `' . bqSQL($this->_sort) . '`';
if (isset($this->_direction) && Validate::isSortDirection($this->_direction)) {
$this->query .= ' ' . $this->_direction;
}
}
if (($this->_start === 0 || Validate::IsUnsignedInt($this->_start)) && Validate::IsUnsignedInt($this->_limit)) {
$this->query .= ' LIMIT ' . (int) $this->_start . ', ' . (int) $this->_limit;
}
$values = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->query);
foreach ($values as &$value) {
$value['avgPriceSold'] = Tools::displayPrice($value['avgPriceSold'], $currency);
$value['totalPriceSold'] = Tools::displayPrice($value['totalPriceSold'], $currency);
}
unset($value);
$this->_values = $values;
$this->_totalCount = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT FOUND_ROWS()');
}
示例14: _getParentsCategories
/**
* Get Each parent category of this category until the root category
*
* @param integer $id_lang Language ID
* @return array Corresponding categories
*/
public function _getParentsCategories($id_current = NULL)
{
$context = Context::getContext()->cloneContext();
$context->shop = clone $context->shop;
$id_lang = $context->language->id;
$categories = null;
if (count(Category::getCategoriesWithoutParent()) > 1 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && count(Shop::getShops(true, null, true)) != 1) {
$context->shop->id_category = Category::getTopCategory()->id;
} elseif (!$context->shop->id) {
$context->shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
}
$id_shop = $context->shop->id;
while (true) {
$sql = '
SELECT c.*, cl.*
FROM `' . _DB_PREFIX_ . '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') . ')';
if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
$sql .= '
LEFT JOIN `' . _DB_PREFIX_ . 'category_shop` cs
ON (c.`id_category` = cs.`id_category` AND cs.`id_shop` = ' . (int) $id_shop . ')';
}
$sql .= '
WHERE c.`id_category` = ' . (int) $id_current;
if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
$sql .= '
AND cs.`id_shop` = ' . (int) $context->shop->id;
}
$root_category = Category::getRootCategory();
if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP && (!Tools::isSubmit('id_category') || (int) Tools::getValue('id_category') == (int) $root_category->id || (int) $root_category->id == (int) $context->shop->id_category)) {
$sql .= '
AND c.`id_parent` != 0';
}
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if (isset($result[0])) {
$categories[] = $result[0];
} else {
if (!$categories) {
$categories = array();
}
}
if (!$result || $result[0]['id_category'] == $context->shop->id_category) {
return $categories;
}
$id_current = $result[0]['id_parent'];
}
}
示例15: renderList
public function renderList()
{
$this->_select = 'b.*';
$this->_join = 'INNER JOIN `' . _DB_PREFIX_ . 'carrier_lang` b ON a.id_carrier = b.id_carrier' . Shop::addSqlRestrictionOnLang('b') . ' AND b.id_lang = ' . (int) $this->context->language->id . ' LEFT JOIN `' . _DB_PREFIX_ . 'carrier_tax_rules_group_shop` ctrgs ON (a.`id_carrier` = ctrgs.`id_carrier` AND ctrgs.id_shop=' . (int) $this->context->shop->id . ')';
$this->_use_found_rows = false;
// Removes the Recommended modules button
unset($this->page_header_toolbar_btn['modules-list']);
// test if need to show header alert.
$sql = 'SELECT COUNT(1) FROM `' . _DB_PREFIX_ . 'carrier` WHERE deleted = 0 AND id_reference > 2';
$showHeaderAlert = Db::getInstance()->query($sql)->fetchColumn(0) == 0;
// Assign them in two steps! Because renderModulesList needs it before to be called.
$this->context->smarty->assign('panel_title', $this->trans('Use one of our recommended carrier modules', array(), 'Admin.Shipping.Feature'));
$this->context->smarty->assign(array('showHeaderAlert' => $showHeaderAlert, 'modules_list' => $this->renderModulesList('back-office,AdminCarriers,new')));
return parent::renderList();
}