本文整理汇总了PHP中Shop::addSqlAssociation方法的典型用法代码示例。如果您正苦于以下问题:PHP Shop::addSqlAssociation方法的具体用法?PHP Shop::addSqlAssociation怎么用?PHP Shop::addSqlAssociation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shop
的用法示例。
在下文中一共展示了Shop::addSqlAssociation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEmployeesByProduct
/**
* Return list of employees
*
* @return array|false Employees or false
*/
public static function getEmployeesByProduct($id_product)
{
$sql = 'SELECT e.*, CONCAT(e.firstName, \' \', e.lastName) as fullName
FROM `' . _DB_PREFIX_ . 'employee` e
' . Shop::addSqlAssociation('employee', 's') . '
JOIN `' . _DB_PREFIX_ . 'employee_product` ep ON (ep.`id_employee` = e.`id_employee`)
WHERE ep.`id_product`=' . $id_product . '
AND e.id_profile IN (' . Configuration::get('APH_PROFILE_STORE_OWNER') . ', ' . Configuration::get('APH_PROFILE_STORE_EMPLOYEE') . ')
ORDER BY `lastname` ASC';
$e = Db::getInstance()->executeS($sql);
$employees = array();
foreach ($e as &$employee) {
$employees[$employee['id_employee']] = $employee;
$employees[$employee['id_employee']]['text_color'] = '';
$employees[$employee['id_employee']]['bg_color'] = '';
$employees[$employee['id_employee']]['badge_style'] = '';
if (!empty($employee['bo_color'])) {
$employees[$employee['id_employee']]['text_color'] = Tools::getBrightness($employee['bo_color']) < 128 ? 'white' : '#383838';
$employees[$employee['id_employee']]['bg_color'] = $employee['bo_color'];
$employees[$employee['id_employee']]['badge_style'] = '.badge.employee_' . $employee['id_employee'] . '.active {
background-color: ' . $employees[$employee['id_employee']]['bg_color'] . ';
border-color: ' . $employees[$employee['id_employee']]['bg_color'] . ';
color: ' . $employees[$employee['id_employee']]['text_color'] . ';
}
.badge.employee_' . $employee['id_employee'] . '.notactive {
background-color: #fff;
border-color: ' . $employees[$employee['id_employee']]['bg_color'] . ';
color: ' . $employees[$employee['id_employee']]['bg_color'] . ';
}';
}
}
return $employees;
}
示例2: 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;
}
示例3: 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);
}
示例4: renderList
public function renderList()
{
$this->addRowAction('details');
$this->toolbar_btn = array();
// disables link
$this->list_no_link = true;
// query
$this->_select = 'a.id_product as id, COUNT(pa.id_product_attribute) as variations, SUM(s.usable_quantity+s.usable_quantity_remainder) as stock';
$this->_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa ON (pa.id_product = a.id_product)
' . Shop::addSqlAssociation('product_attribute', 'pa', false) . '
INNER JOIN `' . _DB_PREFIX_ . 'stock` s ON (s.id_product = a.id_product)';
$this->_group = 'GROUP BY a.id_product';
self::$currentIndex .= '&coverage_period=' . (int) $this->getCurrentCoveragePeriod() . '&warn_days=' . (int) $this->getCurrentWarning();
if ($this->getCurrentCoverageWarehouse() != -1) {
$this->_where .= ' AND s.id_warehouse = ' . (int) $this->getCurrentCoverageWarehouse();
self::$currentIndex .= '&id_warehouse=' . (int) $this->getCurrentCoverageWarehouse();
}
// Hack for multi shop ..
$this->_where .= ' AND b.id_shop = 1';
$this->tpl_list_vars['stock_cover_periods'] = $this->stock_cover_periods;
$this->tpl_list_vars['stock_cover_cur_period'] = $this->getCurrentCoveragePeriod();
$this->tpl_list_vars['stock_cover_warehouses'] = $this->stock_cover_warehouses;
$this->tpl_list_vars['stock_cover_cur_warehouse'] = $this->getCurrentCoverageWarehouse();
$this->tpl_list_vars['stock_cover_warn_days'] = $this->getCurrentWarning();
$this->ajax_params = array('period' => $this->getCurrentCoveragePeriod(), 'id_warehouse' => $this->getCurrentCoverageWarehouse(), 'warn_days' => $this->getCurrentWarning());
$this->displayInformation($this->l('Considering the coverage period chosen and the quantity of products/combinations that you sold.'));
$this->displayInformation($this->l('this interface gives you an idea of when a product will run out of stock.'));
return $this->adminControllerRenderList();
}
示例5: __construct
public function __construct()
{
$this->bootstrap = true;
$this->table = 'alias';
$this->className = 'Alias';
$this->lang = false;
parent::__construct();
// Alias fields
$this->addRowAction('edit');
$this->addRowAction('delete');
if (!Tools::getValue('realedit')) {
$this->deleted = false;
}
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash'));
$this->fields_list = array('alias' => array('title' => $this->l('Aliases')), 'search' => array('title' => $this->l('Search')), 'active' => array('title' => $this->l('Status'), 'class' => 'fixed-width-sm', 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false));
// Search options
$current_file_name = array_reverse(explode('/', $_SERVER['SCRIPT_NAME']));
$cron_url = Tools::getHttpHost(true, true) . __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_) . '/searchcron.php?full=1&token=' . substr(_COOKIE_KEY_, 34, 8);
list($total, $indexed) = Db::getInstance()->getRow('SELECT COUNT(*) as "0", SUM(product_shop.indexed) as "1" FROM ' . _DB_PREFIX_ . 'product p ' . Shop::addSqlAssociation('product', 'p') . ' WHERE product_shop.`visibility` IN ("both", "search") AND product_shop.`active` = 1');
$this->fields_options = array('indexation' => array('title' => $this->l('Indexing'), 'icon' => 'icon-cogs', 'info' => '<p>' . $this->l('The "indexed" products have been analyzed by PrestaShop and will appear in the results of a Front Office search.') . '<br />
' . $this->l('Indexed products') . ' <strong>' . (int) $indexed . ' / ' . (int) $total . '</strong>.
</p>
<p>' . $this->l('Building the product index may take a few minutes.') . $this->l('If your server stops before the process ends, you can resume the indexing by clicking "Add missing products."') . '</p>
<a href="searchcron.php?token=' . substr(_COOKIE_KEY_, 34, 8) . '&redirect=1" class="btn-link"><i class="icon-external-link-sign"></i> ' . $this->l('Add missing products to the index.') . '</a><br />
<a href="searchcron.php?full=1&token=' . substr(_COOKIE_KEY_, 34, 8) . '&redirect=1" class="btn-link"><i class="icon-external-link-sign"></i> ' . $this->l('Re-build the entire index.') . '</a><br /><br />
' . $this->l('You can set a cron job that will rebuild your index using the following URL:') . ' <a href="' . Tools::safeOutput($cron_url) . '"><i class="icon-external-link-sign"></i> ' . Tools::safeOutput($cron_url) . '</a>', 'fields' => array('PS_SEARCH_INDEXATION' => array('title' => $this->l('Indexing'), 'validation' => 'isBool', 'type' => 'bool', 'cast' => 'intval', 'desc' => $this->l('Enable the automatic indexing of products. If you enable this feature, the products will be indexed in the search automatically when they are saved. If the feature is disabled, you will have to index products manually by using the links provided in the field set.'))), 'submit' => array('title' => $this->l('Save'))), 'search' => array('title' => $this->l('Search'), 'icon' => 'icon-search', 'fields' => array('PS_SEARCH_AJAX' => array('title' => $this->l('Ajax search'), 'validation' => 'isBool', 'type' => 'bool', 'cast' => 'intval', 'hint' => array($this->l('Enable ajax search for your visitors.'), $this->l('With ajax search, the first 10 products matching the user query will appear in real time below the input field.'))), 'PS_INSTANT_SEARCH' => array('title' => $this->l('Instant search'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'hint' => array($this->l('Enable instant search for your visitors?'), $this->l('With instant search, the results will appear immediately as the user writes a query.'))), 'PS_SEARCH_MINWORDLEN' => array('title' => $this->l('Minimum word length (in characters)'), 'hint' => $this->l('Only words this size or larger will be indexed.'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_BLACKLIST' => array('title' => $this->l('Blacklisted words'), 'validation' => 'isGenericName', 'hint' => $this->l('Please enter the index words separated by a "|".'), 'type' => 'textLang')), 'submit' => array('title' => $this->l('Save'))), 'relevance' => array('title' => $this->l('Weight'), 'icon' => 'icon-cogs', 'info' => $this->l('The "weight" represents its importance and relevance for the ranking of the products when completing a new search.') . '<br />
' . $this->l('A word with a weight of eight will have four times more value than a word with a weight of two.') . '<br /><br />
' . $this->l('We advise you to set a greater weight for words which appear in the name or reference of a product. This will allow the search results to be as precise and relevant as possible.') . '<br /><br />
' . $this->l('Setting a weight to 0 will exclude that field from search index. Re-build of the entire index is required when changing to or from 0'), 'fields' => array('PS_SEARCH_WEIGHT_PNAME' => array('title' => $this->l('Product name weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_REF' => array('title' => $this->l('Reference weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_SHORTDESC' => array('title' => $this->l('Short description weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_DESC' => array('title' => $this->l('Description weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_CNAME' => array('title' => $this->l('Category weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_MNAME' => array('title' => $this->l('Manufacturer weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_TAG' => array('title' => $this->l('Tags weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_ATTRIBUTE' => array('title' => $this->l('Attributes weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_FEATURE' => array('title' => $this->l('Features weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval')), 'submit' => array('title' => $this->l('Save'))));
}
开发者ID:carloslastresDev,项目名称:HealthyTaiwan_UsingPrestaShop,代码行数:30,代码来源:AdminSearchConfController.php
示例6: getProductsCollection
/**
* Lists of items
* @param int $iIdLang
* @param bool $active
* @return array
*/
public static function getProductsCollection($iIdLang = null, $bActive = true)
{
if (!Validate::isBool($bActive)) {
die(Tools::displayError());
}
if (is_null($iIdLang)) {
$iIdLang = (int) Context::getContext()->language->id;
}
$sSQL = '
SELECT r.`id_product`
FROM `' . _DB_PREFIX_ . 'now_mea_home` r
' . Shop::addSqlAssociation('now_mea_home', 'r') . '
LEFT JOIN `' . _DB_PREFIX_ . 'now_product_type_product` pt ON (pt.`id_product` = r.`id_product`)
WHERE 1 ' . ($bActive ? ' AND r.`active` = 1 ' : '') . '
AND pt.`id_now_product_type_product` IS NULL
ORDER BY RAND() LIMIT 0 , ' . Configuration::get('NOW_MEA_HOME_NB_PRODUCT');
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sSQL);
$aProducts = array();
foreach ($result as $row) {
$oProduct = new Product($row['id_product'], false, $iIdLang);
$oProduct->loadStockData();
$aProducts[] = $oProduct;
}
return $aProducts;
}
示例7: __construct
public function __construct()
{
$this->table = 'alias';
$this->className = 'Alias';
$this->lang = false;
parent::__construct();
// Alias fields
$this->addRowAction('edit');
$this->addRowAction('delete');
if (!Tools::getValue('realedit')) {
$this->deleted = false;
}
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
$this->fields_list = array('alias' => array('title' => $this->l('Aliases'), 'width' => 'auto'), 'search' => array('title' => $this->l('Search'), 'width' => 100), 'active' => array('title' => $this->l('Status'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false));
// Search options
$current_file_name = array_reverse(explode('/', $_SERVER['SCRIPT_NAME']));
$cron_url = Tools::getHttpHost(true, true) . __PS_BASE_URI__ . substr($_SERVER['SCRIPT_NAME'], strlen(__PS_BASE_URI__), -strlen($current_file_name['0'])) . 'searchcron.php?full=1&token=' . substr(_COOKIE_KEY_, 34, 8);
list($total, $indexed) = Db::getInstance()->getRow('SELECT COUNT(*) as "0", SUM(product_shop.indexed) as "1" FROM ' . _DB_PREFIX_ . 'product p ' . Shop::addSqlAssociation('product', 'p'));
$this->fields_options = array('indexation' => array('title' => $this->l('Indexation'), 'icon' => 'search', 'info' => $this->l('The "indexed" products have been analyzed by PrestaShop and will appear in the results of the Front Office search.') . '<br />
' . $this->l('Indexed products:') . ' <b>' . (int) $indexed . ' / ' . (int) $total . '</b>.
</p>
<p>' . $this->l('Building the product index can take a few minutes or more.') . $this->l('If your server stops the process before it ends, you can resume the indexation by clicking "Add missing products."') . '</p>
-> <a href="searchcron.php?token=' . substr(_COOKIE_KEY_, 34, 8) . '&redirect=1" class="bold">' . $this->l('Add missing products to index.') . '</a><br />
-> <a href="searchcron.php?full=1&token=' . substr(_COOKIE_KEY_, 34, 8) . '&redirect=1" class="bold">' . $this->l('Re-build entire index.') . '</a><br /><br />
' . $this->l('You can set a cron job that will rebuild your index using the following URL:') . ' <a href="' . $cron_url . '">' . $cron_url . '</a>', 'fields' => array('PS_SEARCH_INDEXATION' => array('title' => $this->l('Indexation'), 'validation' => 'isBool', 'type' => 'bool', 'cast' => 'intval', 'desc' => $this->l('Enable automatic indexation of the products. If you enable this feature, the products will be indexed in the search automatically when they are saved, but if the feature is disabled, you will have to index the products manually by using the links provided in this fieldset.')))), 'search' => array('title' => $this->l('Search'), 'icon' => 'search', 'fields' => array('PS_SEARCH_AJAX' => array('title' => $this->l('Ajax search'), 'validation' => 'isBool', 'type' => 'bool', 'cast' => 'intval', 'desc' => $this->l('Enable ajax search for your visitors.') . '<br />' . $this->l('With ajax search, the first 10 products matching the user query will appear in real time below the input field.')), 'PS_INSTANT_SEARCH' => array('title' => $this->l('Instant search'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'desc' => $this->l('Enable instant search for your visitors.') . '<br />' . $this->l('With instant search, the results will appear immediately as the user writes a query.')), 'PS_SEARCH_MINWORDLEN' => array('title' => $this->l('Minimum word length (in characters)'), 'desc' => $this->l('Only words this size or larger will be indexed.'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_BLACKLIST' => array('title' => $this->l('Blacklisted words'), 'size' => 35, 'validation' => 'isGenericName', 'desc' => $this->l('Please enter the words separated by a "|".'), 'type' => 'textLang')), 'submit' => array()), 'relevance' => array('title' => $this->l('Weight'), 'icon' => 'weight', 'info' => $this->l('The "weight" represents its importance and relevance for the ranking of the products when try a new search.') . '<br />
' . $this->l('A word with a weight of 8 will have 4 times more value than a word with a weight of 2.') . '<br /><br />
' . $this->l('That\'s why we advise to set a greater weight for words which appear in the name or reference of a product than the ones in the description. Thus, the search results will be as precise and relevant as possible.'), 'fields' => array('PS_SEARCH_WEIGHT_PNAME' => array('title' => $this->l('Product name weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_REF' => array('title' => $this->l('Reference weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_SHORTDESC' => array('title' => $this->l('Short description weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_DESC' => array('title' => $this->l('Description weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_CNAME' => array('title' => $this->l('Category weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_MNAME' => array('title' => $this->l('Manufacturer weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_TAG' => array('title' => $this->l('Tags weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_ATTRIBUTE' => array('title' => $this->l('Attributes weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_FEATURE' => array('title' => $this->l('Features weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'))));
}
示例8: getTaxRulesGroups
public static function getTaxRulesGroups($only_active = true)
{
return Db::getInstance()->executeS('
SELECT DISTINCT g.id_tax_rules_group, g.name, g.active
FROM `' . _DB_PREFIX_ . 'tax_rules_group` g' . Shop::addSqlAssociation('tax_rules_group', 'g') . ($only_active ? ' WHERE g.`active` = 1' : '') . '
ORDER BY name ASC');
}
示例9: 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;
}
示例10: renderList
/**
* AdminController::renderList() override
* @see AdminController::renderList()
*/
public function renderList()
{
// sets actions
$this->addRowAction('details');
$this->addRowAction('addstock');
$this->addRowAction('removestock');
if (count(Warehouse::getWarehouses()) > 1) {
$this->addRowAction('transferstock');
}
// no link on list rows
$this->list_no_link = true;
// inits toolbar
$this->toolbar_btn = array();
// overrides query
$this->_select = 'a.id_product as id, COUNT(pa.id_product_attribute) as variations';
$this->_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa ON (pa.id_product = a.id_product)' . Shop::addSqlAssociation('product_attribute', 'pa', false);
$this->_where = 'AND a.is_virtual = 0';
$this->_group = 'GROUP BY a.id_product';
// displays informations
$this->displayInformation($this->l('This interface allows you to manage product stock and their variations.') . '<br />');
$this->displayInformation($this->l('Through this interface, you can increase and decrease product stock for an given warehouse.'));
$this->displayInformation($this->l('Furthermore, you can move product quantities between warehouses, or within one warehouse.') . '<br />');
$this->displayInformation($this->l('If you want to increase quantities of multiple products at once, you can use the "Supply orders" page under the "Stock" menu.') . '<br />');
$this->displayInformation($this->l('Finally, you need to provide the quantity that you\'ll be adding: "Usable for sale" means that this quantity will be available in your shop(s), otherwise it will be considered reserved (i.e. for other purposes).'));
return parent::renderList();
}
示例11: getStores
public static function getStores()
{
$stores = Db::getInstance()->executeS('
SELECT s.id_store AS `id`, s.*
FROM ' . _DB_PREFIX_ . 'store s
' . Shop::addSqlAssociation('store', 's') . '
WHERE s.active = 1');
return $stores;
}
示例12: isProductTyped
/**
* Permet de tester si un produit est typer ou pas
* @param $iIdProduct
* @param int $iIdNowProductType
* @return bool
*/
public static function isProductTyped($iIdProduct, $iIdNowProductType = null)
{
$sSQL = '
SELECT 1
FROM `' . _DB_PREFIX_ . 'now_product_type_product` pt
' . Shop::addSqlAssociation('now_product_type_product', 'pt') . '
WHERE pt.`id_product` = ' . (int) $iIdProduct . (!is_null($iIdNowProductType) ? ' AND pt.`id_now_product_type` = ' . (int) $iIdNowProductType : '');
return (bool) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sSQL);
}
示例13: getFeatures
/**
* Get all features for a given language
*
* @param int $id_lang Language id
* @return array Multiple arrays with feature's data
*/
public static function getFeatures($id_lang, $with_shop = true)
{
return Db::getInstance()->executeS('
SELECT DISTINCT f.id_feature, f.*, fl.*
FROM `' . _DB_PREFIX_ . 'feature` f
' . ($with_shop ? Shop::addSqlAssociation('feature', 'f') : '') . '
LEFT JOIN `' . _DB_PREFIX_ . 'feature_lang` fl ON (f.`id_feature` = fl.`id_feature` AND fl.`id_lang` = ' . (int) $id_lang . ')
ORDER BY f.`position` ASC');
}
示例14: hookRightColumn
public function hookRightColumn($params)
{
$this->smarty->assign('store_img', Configuration::get('BLOCKSTORE_IMG'));
$sql = 'SELECT COUNT(*)
FROM ' . _DB_PREFIX_ . 'store s' . Shop::addSqlAssociation('store', 's');
$total = Db::getInstance()->getValue($sql);
if ($total > 0) {
return $this->display(__FILE__, 'blockstore.tpl');
}
}
示例15: 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);
}
}
}