[+] BO : added a new option for the products : do they appear in the catalog, in the search, both or neither
This commit is contained in:
1 parent
02689ebd3b
commit
a4d25e7a2a
15 files changed
+134
-30
No files matched your search
@@ -85,24 +85,32 @@
|
|||||||
<table cellpadding="5" style="width: 40%; float: left; margin-left: 10px;">
|
<table cellpadding="5" style="width: 40%; float: left; margin-left: 10px;">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="col-left">
|
<td class="col-left">
|
||||||
|
<label class="text">{l s='Status:'}</label>
|
||||||
|
</td>
|
||||||
<label class="text">{l s='Status:'}</label></td>
|
|
||||||
<td style="padding-bottom:5px;">
|
<td style="padding-bottom:5px;">
|
||||||
<ul class="listForm">
|
<ul class="listForm">
|
||||||
<li>
|
<li>
|
||||||
<input onclick="toggleDraftWarning(false);showOptions(true);" type="radio" name="active" id="active_on" value="1" {if $product->active}checked="checked" {/if} />
|
<input onclick="toggleDraftWarning(false);showOptions(true);" type="radio" name="active" id="active_on" value="1" {if $product->active}checked="checked" {/if} />
|
||||||
<label for="active_on" class="radioCheck">
|
<label for="active_on" class="radioCheck">{l s='Enabled'}</label>
|
||||||
{l s='Enabled'}</label>
|
</li>
|
||||||
</li>
|
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<input onclick="toggleDraftWarning(true);showOptions(false);" type="radio" name="active" id="active_off" value="0" {if !$product->active}checked="checked"{/if} />
|
<input onclick="toggleDraftWarning(true);showOptions(false);" type="radio" name="active" id="active_off" value="0" {if !$product->active}checked="checked"{/if} />
|
||||||
<label for="active_off" class="radioCheck">{l s='Disabled'} </label>
|
<label for="active_off" class="radioCheck">{l s='Disabled'}</label>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="col-left"><label>{l s='Visibility:'}</label></td>
|
||||||
|
<td style="padding-bottom:5px;">
|
||||||
|
<select name="visibility" id="visibility">
|
||||||
|
<option value="both" {if $product->visibility == 'both'}selected="selected"{/if} >{l s='Everywhere'}</option>
|
||||||
|
<option value="catalog" {if $product->visibility == 'catalog'}selected="selected"{/if} >{l s='Catalog only'}</option>
|
||||||
|
<option value="search" {if $product->visibility == 'search'}selected="selected"{/if} >{l s='Search only'}</option>
|
||||||
|
<option value="none" {if $product->visibility == 'none'}selected="selected"{/if}>{l s='Nowhere'}</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr id="product_options" {if !$product->active}style="display:none"{/if} >
|
<tr id="product_options" {if !$product->active}style="display:none"{/if} >
|
||||||
<td class="col-left"><label>{l s='Options:'}</label></td>
|
<td class="col-left"><label>{l s='Options:'}</label></td>
|
||||||
<td style="padding-bottom:5px;">
|
<td style="padding-bottom:5px;">
|
||||||
|
|||||||
@@ -579,7 +579,11 @@ class CategoryCore extends ObjectModel
|
|||||||
$context = Context::getContext();
|
$context = Context::getContext();
|
||||||
if (!$check_access || !$this->checkAccess($context->customer->id))
|
if (!$check_access || !$this->checkAccess($context->customer->id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
$front = true;
|
||||||
|
if (!in_array($context->controller->controller_type, array('front', 'modulefront')))
|
||||||
|
$front = false;
|
||||||
|
|
||||||
if ($p < 1) $p = 1;
|
if ($p < 1) $p = 1;
|
||||||
|
|
||||||
if (empty($order_by))
|
if (empty($order_by))
|
||||||
@@ -618,6 +622,7 @@ class CategoryCore extends ObjectModel
|
|||||||
'.Shop::addSqlAssociation('product', 'p').'
|
'.Shop::addSqlAssociation('product', 'p').'
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON p.`id_product` = cp.`id_product`
|
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON p.`id_product` = cp.`id_product`
|
||||||
WHERE cp.`id_category` = '.(int)$this->id.
|
WHERE cp.`id_category` = '.(int)$this->id.
|
||||||
|
($front ? ' AND p.`visibility` IN ("both", "catalog")' : '').
|
||||||
($active ? ' AND p.`active` = 1' : '').
|
($active ? ' AND p.`active` = 1' : '').
|
||||||
($id_supplier ? 'AND p.id_supplier = '.(int)$id_supplier : '');
|
($id_supplier ? 'AND p.id_supplier = '.(int)$id_supplier : '');
|
||||||
return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
|
return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
|
||||||
@@ -666,6 +671,7 @@ class CategoryCore extends ObjectModel
|
|||||||
WHERE asso_shop_product.`id_shop` = '.(int)Context::getContext()->shop->id.'
|
WHERE asso_shop_product.`id_shop` = '.(int)Context::getContext()->shop->id.'
|
||||||
AND cp.`id_category` = '.(int)$this->id
|
AND cp.`id_category` = '.(int)$this->id
|
||||||
.($active ? ' AND p.`active` = 1' : '')
|
.($active ? ' AND p.`active` = 1' : '')
|
||||||
|
.($front ? ' AND p.`visibility` IN ("both", "catalog")' : '')
|
||||||
.($id_supplier ? ' AND p.id_supplier = '.(int)$id_supplier : '');
|
.($id_supplier ? ' AND p.id_supplier = '.(int)$id_supplier : '');
|
||||||
|
|
||||||
if ($random === true)
|
if ($random === true)
|
||||||
|
|||||||
+23
-12
@@ -276,6 +276,10 @@ class ManufacturerCore extends ObjectModel
|
|||||||
if (!$context)
|
if (!$context)
|
||||||
$context = Context::getContext();
|
$context = Context::getContext();
|
||||||
|
|
||||||
|
$front = true;
|
||||||
|
if (!in_array($context->controller->controller_type, array('front', 'modulefront')))
|
||||||
|
$front = false;
|
||||||
|
|
||||||
if ($p < 1)
|
if ($p < 1)
|
||||||
$p = 1;
|
$p = 1;
|
||||||
|
|
||||||
@@ -299,6 +303,7 @@ class ManufacturerCore extends ObjectModel
|
|||||||
'.Shop::addSqlAssociation('product', 'p').'
|
'.Shop::addSqlAssociation('product', 'p').'
|
||||||
WHERE p.id_manufacturer = '.(int)$id_manufacturer
|
WHERE p.id_manufacturer = '.(int)$id_manufacturer
|
||||||
.($active ? ' AND p.`active` = 1' : '').'
|
.($active ? ' AND p.`active` = 1' : '').'
|
||||||
|
'.($front ? ' AND p.`visibility` IN ("both", "catalog")' : '').'
|
||||||
AND p.`id_product` IN (
|
AND p.`id_product` IN (
|
||||||
SELECT cp.`id_product`
|
SELECT cp.`id_product`
|
||||||
FROM `'._DB_PREFIX_.'category_group` cg
|
FROM `'._DB_PREFIX_.'category_group` cg
|
||||||
@@ -350,8 +355,9 @@ class ManufacturerCore extends ObjectModel
|
|||||||
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m
|
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m
|
||||||
ON (m.`id_manufacturer` = p.`id_manufacturer`)
|
ON (m.`id_manufacturer` = p.`id_manufacturer`)
|
||||||
'.Product::sqlStock('p', 0).'
|
'.Product::sqlStock('p', 0).'
|
||||||
WHERE p.`id_manufacturer` = '.(int)$id_manufacturer.($active ? '
|
WHERE p.`id_manufacturer` = '.(int)$id_manufacturer.'
|
||||||
AND p.`active` = 1' : '').'
|
'.($active ? ' AND p.`active` = 1' : '').'
|
||||||
|
'.($front ? ' AND p.`visibility` IN ("both", "catalog")' : '').'
|
||||||
AND p.`id_product` IN (
|
AND p.`id_product` IN (
|
||||||
SELECT cp.`id_product`
|
SELECT cp.`id_product`
|
||||||
FROM `'._DB_PREFIX_.'category_group` cg
|
FROM `'._DB_PREFIX_.'category_group` cg
|
||||||
@@ -376,15 +382,20 @@ class ManufacturerCore extends ObjectModel
|
|||||||
|
|
||||||
public function getProductsLite($id_lang)
|
public function getProductsLite($id_lang)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT p.`id_product`, pl.`name`
|
$context = Context::getContext();
|
||||||
FROM `'._DB_PREFIX_.'product` p
|
$front = true;
|
||||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
|
if (!in_array($context->controller->controller_type, array('front', 'modulefront')))
|
||||||
p.`id_product` = pl.`id_product`
|
$front = false;
|
||||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
|
||||||
)
|
return Db::getInstance()->executeS('
|
||||||
WHERE p.`id_manufacturer` = '.(int)$this->id;
|
SELECT p.`id_product`, pl.`name`
|
||||||
|
FROM `'._DB_PREFIX_.'product` p
|
||||||
return Db::getInstance()->executeS($sql);
|
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
|
||||||
|
p.`id_product` = pl.`id_product`
|
||||||
|
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').'
|
||||||
|
)
|
||||||
|
WHERE p.`id_manufacturer` = '.(int)$this->id.
|
||||||
|
($front ? ' AND p.`visibility` IN ("both", "catalog")' : ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -454,4 +465,4 @@ class ManufacturerCore extends ObjectModel
|
|||||||
|
|
||||||
return ($result1 && $result2);
|
return ($result1 && $result2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+34
-1
@@ -174,8 +174,12 @@ class ProductCore extends ObjectModel
|
|||||||
/** @var boolean Show price of Product */
|
/** @var boolean Show price of Product */
|
||||||
public $show_price = true;
|
public $show_price = true;
|
||||||
|
|
||||||
|
/** @var boolean is the product indexed in the search index? */
|
||||||
public $indexed = 0;
|
public $indexed = 0;
|
||||||
|
|
||||||
|
/** @var string ENUM('both', 'catalog', 'search', 'none') front office visibility */
|
||||||
|
public $visibility;
|
||||||
|
|
||||||
/** @var string Object creation date */
|
/** @var string Object creation date */
|
||||||
public $date_add;
|
public $date_add;
|
||||||
|
|
||||||
@@ -260,6 +264,7 @@ class ProductCore extends ObjectModel
|
|||||||
'ean13' => array('type' => self::TYPE_STRING, 'validate' => 'isEan13', 'size' => 13),
|
'ean13' => array('type' => self::TYPE_STRING, 'validate' => 'isEan13', 'size' => 13),
|
||||||
'upc' => array('type' => self::TYPE_STRING, 'validate' => 'isUpc', 'size' => 12),
|
'upc' => array('type' => self::TYPE_STRING, 'validate' => 'isUpc', 'size' => 12),
|
||||||
'indexed' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
'indexed' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||||
|
'visibility' => array('type' => self::TYPE_STRING, 'validate' => 'isProductVisibility', 'values' => array('both', 'catalog', 'search', 'none'), 'default' => 'both'),
|
||||||
'cache_is_pack' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
'cache_is_pack' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||||
'cache_default_attribute' => array('type' => self::TYPE_INT),
|
'cache_default_attribute' => array('type' => self::TYPE_INT),
|
||||||
'is_virtual' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
'is_virtual' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||||
@@ -925,6 +930,10 @@ class ProductCore extends ObjectModel
|
|||||||
if (!$context)
|
if (!$context)
|
||||||
$context = Context::getContext();
|
$context = Context::getContext();
|
||||||
|
|
||||||
|
$front = true;
|
||||||
|
if (!in_array($context->controller->controller_type, array('front', 'modulefront')))
|
||||||
|
$front = false;
|
||||||
|
|
||||||
if (!Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way))
|
if (!Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way))
|
||||||
die (Tools::displayError());
|
die (Tools::displayError());
|
||||||
if ($order_by == 'id_product' || $order_by == 'price' || $order_by == 'date_add')
|
if ($order_by == 'id_product' || $order_by == 'price' || $order_by == 'date_add')
|
||||||
@@ -955,6 +964,7 @@ class ProductCore extends ObjectModel
|
|||||||
($id_category ? 'LEFT JOIN `'._DB_PREFIX_.'category_product` c ON (c.`id_product` = p.`id_product`)' : '').'
|
($id_category ? 'LEFT JOIN `'._DB_PREFIX_.'category_product` c ON (c.`id_product` = p.`id_product`)' : '').'
|
||||||
WHERE pl.`id_lang` = '.(int)$id_lang.
|
WHERE pl.`id_lang` = '.(int)$id_lang.
|
||||||
($id_category ? ' AND c.`id_category` = '.(int)$id_category : '').
|
($id_category ? ' AND c.`id_category` = '.(int)$id_category : '').
|
||||||
|
($front ? ' AND p.`visibility` IN ("both", "catalog")' : '').
|
||||||
($only_active ? ' AND p.`active` = 1' : '').'
|
($only_active ? ' AND p.`active` = 1' : '').'
|
||||||
ORDER BY '.(isset($order_by_prefix) ? pSQL($order_by_prefix).'.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way).
|
ORDER BY '.(isset($order_by_prefix) ? pSQL($order_by_prefix).'.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way).
|
||||||
($limit > 0 ? ' LIMIT '.(int)$start.','.(int)$limit : '');
|
($limit > 0 ? ' LIMIT '.(int)$start.','.(int)$limit : '');
|
||||||
@@ -969,11 +979,16 @@ class ProductCore extends ObjectModel
|
|||||||
if (!$context)
|
if (!$context)
|
||||||
$context = Context::getContext();
|
$context = Context::getContext();
|
||||||
|
|
||||||
|
$front = true;
|
||||||
|
if (!in_array($context->controller->controller_type, array('front', 'modulefront')))
|
||||||
|
$front = false;
|
||||||
|
|
||||||
$sql = 'SELECT p.`id_product`, pl.`name`
|
$sql = 'SELECT p.`id_product`, pl.`name`
|
||||||
FROM `'._DB_PREFIX_.'product` p
|
FROM `'._DB_PREFIX_.'product` p
|
||||||
'.Shop::addSqlAssociation('product', 'p', false).'
|
'.Shop::addSqlAssociation('product', 'p', false).'
|
||||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` '.Shop::addSqlRestrictionOnLang('pl').')
|
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` '.Shop::addSqlRestrictionOnLang('pl').')
|
||||||
WHERE pl.`id_lang` = '.(int)$id_lang.'
|
WHERE pl.`id_lang` = '.(int)$id_lang.'
|
||||||
|
'.($front ? ' AND p.`visibility` IN ("both", "catalog")' : '').'
|
||||||
ORDER BY pl.`name`';
|
ORDER BY pl.`name`';
|
||||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||||
}
|
}
|
||||||
@@ -1775,6 +1790,10 @@ class ProductCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
if (!$context)
|
if (!$context)
|
||||||
$context = Context::getContext();
|
$context = Context::getContext();
|
||||||
|
|
||||||
|
$front = true;
|
||||||
|
if (!in_array($context->controller->controller_type, array('front', 'modulefront')))
|
||||||
|
$front = false;
|
||||||
|
|
||||||
if ($page_number < 0) $page_number = 0;
|
if ($page_number < 0) $page_number = 0;
|
||||||
if ($nb_products < 1) $nb_products = 10;
|
if ($nb_products < 1) $nb_products = 10;
|
||||||
@@ -1808,6 +1827,7 @@ class ProductCore extends ObjectModel
|
|||||||
INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY
|
INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY
|
||||||
)
|
)
|
||||||
) > 0
|
) > 0
|
||||||
|
'.($front ? ' AND p.`visibility` IN ("both", "catalog")' : '').'
|
||||||
AND p.`id_product` IN (
|
AND p.`id_product` IN (
|
||||||
SELECT cp.`id_product`
|
SELECT cp.`id_product`
|
||||||
FROM `'._DB_PREFIX_.'category_group` cg
|
FROM `'._DB_PREFIX_.'category_group` cg
|
||||||
@@ -1851,6 +1871,8 @@ class ProductCore extends ObjectModel
|
|||||||
Product::sqlStock('p', 0, false, null, $sql);
|
Product::sqlStock('p', 0, false, null, $sql);
|
||||||
|
|
||||||
$sql->where('p.`active` = 1');
|
$sql->where('p.`active` = 1');
|
||||||
|
if ($front)
|
||||||
|
$sql->where('p.`visibility` IN ("both", "catalog")');
|
||||||
$sql->where('
|
$sql->where('
|
||||||
DATEDIFF(
|
DATEDIFF(
|
||||||
p.`date_add`,
|
p.`date_add`,
|
||||||
@@ -1923,6 +1945,10 @@ class ProductCore extends ObjectModel
|
|||||||
if (!$context)
|
if (!$context)
|
||||||
$context = Context::getContext();
|
$context = Context::getContext();
|
||||||
|
|
||||||
|
$front = true;
|
||||||
|
if (!in_array($context->controller->controller_type, array('front', 'modulefront')))
|
||||||
|
$front = false;
|
||||||
|
|
||||||
$current_date = date('Y-m-d H:i:s');
|
$current_date = date('Y-m-d H:i:s');
|
||||||
$ids_product = Product::_getProductIdByDate((!$beginning ? $current_date : $beginning), (!$ending ? $current_date : $ending), $context);
|
$ids_product = Product::_getProductIdByDate((!$beginning ? $current_date : $beginning), (!$ending ? $current_date : $ending), $context);
|
||||||
|
|
||||||
@@ -1965,7 +1991,8 @@ class ProductCore extends ObjectModel
|
|||||||
AND tr.`id_state` = 0)
|
AND tr.`id_state` = 0)
|
||||||
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)
|
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)
|
||||||
'.Product::sqlStock('p', 0).'
|
'.Product::sqlStock('p', 0).'
|
||||||
WHERE p.id_product = '.(int)$id_product;
|
WHERE p.id_product = '.(int)$id_product.'
|
||||||
|
'.($front ? ' AND p.`visibility` IN ("both", "catalog")' : '');
|
||||||
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
||||||
|
|
||||||
return Product::getProductProperties($id_lang, $row);
|
return Product::getProductProperties($id_lang, $row);
|
||||||
@@ -2000,6 +2027,10 @@ class ProductCore extends ObjectModel
|
|||||||
$current_date = date('Y-m-d H:i:s');
|
$current_date = date('Y-m-d H:i:s');
|
||||||
$ids_product = Product::_getProductIdByDate((!$beginning ? $current_date : $beginning), (!$ending ? $current_date : $ending), $context);
|
$ids_product = Product::_getProductIdByDate((!$beginning ? $current_date : $beginning), (!$ending ? $current_date : $ending), $context);
|
||||||
|
|
||||||
|
$front = true;
|
||||||
|
if (!in_array($context->controller->controller_type, array('front', 'modulefront')))
|
||||||
|
$front = false;
|
||||||
|
|
||||||
$groups = FrontController::getCurrentCustomerGroups();
|
$groups = FrontController::getCurrentCustomerGroups();
|
||||||
$sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1');
|
$sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1');
|
||||||
|
|
||||||
@@ -2010,6 +2041,7 @@ class ProductCore extends ObjectModel
|
|||||||
'.Shop::addSqlAssociation('product', 'p').'
|
'.Shop::addSqlAssociation('product', 'p').'
|
||||||
WHERE p.`active` = 1
|
WHERE p.`active` = 1
|
||||||
AND p.`show_price` = 1
|
AND p.`show_price` = 1
|
||||||
|
'.($front ? ' AND p.`visibility` IN ("both", "catalog")' : '').'
|
||||||
'.((!$beginning && !$ending) ? 'AND p.`id_product` IN('.((is_array($ids_product) && count($ids_product)) ? implode(', ', array_map('intval', $ids_product)) : 0).')' : '').'
|
'.((!$beginning && !$ending) ? 'AND p.`id_product` IN('.((is_array($ids_product) && count($ids_product)) ? implode(', ', array_map('intval', $ids_product)) : 0).')' : '').'
|
||||||
AND p.`id_product` IN (
|
AND p.`id_product` IN (
|
||||||
SELECT cp.`id_product`
|
SELECT cp.`id_product`
|
||||||
@@ -2053,6 +2085,7 @@ class ProductCore extends ObjectModel
|
|||||||
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
|
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
|
||||||
WHERE p.`active` = 1
|
WHERE p.`active` = 1
|
||||||
AND p.`show_price` = 1
|
AND p.`show_price` = 1
|
||||||
|
'.($front ? ' AND p.`visibility` IN ("both", "catalog")' : '').'
|
||||||
'.((!$beginning && !$ending) ? ' AND p.`id_product` IN ('.((is_array($ids_product) && count($ids_product)) ? implode(', ', $ids_product) : 0).')' : '').'
|
'.((!$beginning && !$ending) ? ' AND p.`id_product` IN ('.((is_array($ids_product) && count($ids_product)) ? implode(', ', $ids_product) : 0).')' : '').'
|
||||||
AND p.`id_product` IN (
|
AND p.`id_product` IN (
|
||||||
SELECT cp.`id_product`
|
SELECT cp.`id_product`
|
||||||
|
|||||||
+6
-3
@@ -214,6 +214,7 @@ class SearchCore
|
|||||||
'.Shop::addSqlAssociation('product', 'p', false).'
|
'.Shop::addSqlAssociation('product', 'p', false).'
|
||||||
WHERE c.`active` = 1
|
WHERE c.`active` = 1
|
||||||
AND p.`active` = 1
|
AND p.`active` = 1
|
||||||
|
AND p.`visibility` IN ("both", "search")
|
||||||
AND indexed = 1
|
AND indexed = 1
|
||||||
AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN (
|
AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN (
|
||||||
SELECT id_group FROM '._DB_PREFIX_.'customer_group
|
SELECT id_group FROM '._DB_PREFIX_.'customer_group
|
||||||
@@ -381,7 +382,8 @@ class SearchCore
|
|||||||
LEFT JOIN '._DB_PREFIX_.'manufacturer m
|
LEFT JOIN '._DB_PREFIX_.'manufacturer m
|
||||||
ON m.id_manufacturer = p.id_manufacturer
|
ON m.id_manufacturer = p.id_manufacturer
|
||||||
WHERE p.indexed = 0
|
WHERE p.indexed = 0
|
||||||
'.($id_product ? 'AND p.id_product = '.(int)$id_product : '').'
|
AND p.visibility IN ("both", "search")
|
||||||
|
'.($id_product ? 'AND p.id_product = '.(int)$id_product : '').'
|
||||||
LIMIT '.(int)$limit
|
LIMIT '.(int)$limit
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -401,11 +403,12 @@ class SearchCore
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Do it even if you already know the product id in order to be sure that it exists
|
// Do it even if you already know the product id in order to be sure that it exists and it needs to be indexed
|
||||||
$products = $db->executeS('
|
$products = $db->executeS('
|
||||||
SELECT id_product
|
SELECT id_product
|
||||||
FROM '._DB_PREFIX_.'product
|
FROM '._DB_PREFIX_.'product
|
||||||
WHERE '.($id_product ? 'id_product = '.(int)$id_product : 'indexed = 0')
|
WHERE visibility IN ("both", "search")
|
||||||
|
AND '.($id_product ? 'id_product = '.(int)$id_product : 'indexed = 0')
|
||||||
);
|
);
|
||||||
|
|
||||||
$ids = array();
|
$ids = array();
|
||||||
|
|||||||
@@ -193,6 +193,11 @@ class SupplierCore extends ObjectModel
|
|||||||
public static function getProducts($id_supplier, $id_lang, $p, $n,
|
public static function getProducts($id_supplier, $id_lang, $p, $n,
|
||||||
$order_by = null, $order_way = null, $get_total = false, $active = true, $active_category = true)
|
$order_by = null, $order_way = null, $get_total = false, $active = true, $active_category = true)
|
||||||
{
|
{
|
||||||
|
$context = Context::getContext();
|
||||||
|
$front = true;
|
||||||
|
if (!in_array($context->controller->controller_type, array('front', 'modulefront')))
|
||||||
|
$front = false;
|
||||||
|
|
||||||
if ($p < 1) $p = 1;
|
if ($p < 1) $p = 1;
|
||||||
if (empty($order_by) || $order_by == 'position') $order_by = 'name';
|
if (empty($order_by) || $order_by == 'position') $order_by = 'name';
|
||||||
if (empty($order_way)) $order_way = 'ASC';
|
if (empty($order_way)) $order_way = 'ASC';
|
||||||
@@ -213,6 +218,7 @@ class SupplierCore extends ObjectModel
|
|||||||
WHERE ps.`id_supplier` = '.(int)$id_supplier.'
|
WHERE ps.`id_supplier` = '.(int)$id_supplier.'
|
||||||
AND ps.id_product_attribute = 0'.
|
AND ps.id_product_attribute = 0'.
|
||||||
($active ? ' AND p.`active` = 1' : '').'
|
($active ? ' AND p.`active` = 1' : '').'
|
||||||
|
'.($front ? ' AND p.`visibility` IN ("both", "catalog")' : '').'
|
||||||
AND p.`id_product` IN (
|
AND p.`id_product` IN (
|
||||||
SELECT cp.`id_product`
|
SELECT cp.`id_product`
|
||||||
FROM `'._DB_PREFIX_.'category_group` cg
|
FROM `'._DB_PREFIX_.'category_group` cg
|
||||||
@@ -271,6 +277,7 @@ class SupplierCore extends ObjectModel
|
|||||||
'.Product::sqlStock('p').'
|
'.Product::sqlStock('p').'
|
||||||
WHERE ps.`id_supplier` = '.(int)$id_supplier.
|
WHERE ps.`id_supplier` = '.(int)$id_supplier.
|
||||||
($active ? ' AND p.`active` = 1' : '').'
|
($active ? ' AND p.`active` = 1' : '').'
|
||||||
|
'.($front ? ' AND p.`visibility` IN ("both", "catalog")' : '').'
|
||||||
AND p.`id_product` IN (
|
AND p.`id_product` IN (
|
||||||
SELECT cp.`id_product`
|
SELECT cp.`id_product`
|
||||||
FROM `'._DB_PREFIX_.'category_group` cg
|
FROM `'._DB_PREFIX_.'category_group` cg
|
||||||
@@ -294,6 +301,11 @@ class SupplierCore extends ObjectModel
|
|||||||
|
|
||||||
public function getProductsLite($id_lang)
|
public function getProductsLite($id_lang)
|
||||||
{
|
{
|
||||||
|
$context = Context::getContext();
|
||||||
|
$front = true;
|
||||||
|
if (!in_array($context->controller->controller_type, array('front', 'modulefront')))
|
||||||
|
$front = false;
|
||||||
|
|
||||||
$sql = '
|
$sql = '
|
||||||
SELECT p.`id_product`,
|
SELECT p.`id_product`,
|
||||||
pl.`name`
|
pl.`name`
|
||||||
@@ -306,6 +318,7 @@ class SupplierCore extends ObjectModel
|
|||||||
ps.`id_product` = p.`id_product`
|
ps.`id_product` = p.`id_product`
|
||||||
AND ps.`id_supplier` = '.(int)$this->id.'
|
AND ps.`id_supplier` = '.(int)$this->id.'
|
||||||
)
|
)
|
||||||
|
'.($front ? ' WHERE p.`visibility` IN ("both", "catalog")' : '').'
|
||||||
GROUP BY p.`id_product`';
|
GROUP BY p.`id_product`';
|
||||||
|
|
||||||
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||||
|
|||||||
@@ -608,6 +608,17 @@ class ValidateCore
|
|||||||
return preg_match('/^[^!<>;?=+#"°{}_$%]*$/u', $list);
|
return preg_match('/^[^!<>;?=+#"°{}_$%]*$/u', $list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for product visibility
|
||||||
|
*
|
||||||
|
* @param string $s visibility to check
|
||||||
|
* @return boolean Validity is ok or not
|
||||||
|
*/
|
||||||
|
public static function isProductVisibility($s)
|
||||||
|
{
|
||||||
|
return preg_match('/^both|catalog|search|none$/i', $s);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for an integer validity
|
* Check for an integer validity
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -259,6 +259,7 @@ class AdminControllerCore extends Controller
|
|||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
$this->controller_type = 'admin';
|
||||||
$this->controller_name = get_class($this);
|
$this->controller_name = get_class($this);
|
||||||
if (strpos($this->controller_name, 'Controller'))
|
if (strpos($this->controller_name, 'Controller'))
|
||||||
$this->controller_name = substr($this->controller_name, 0, -10);
|
$this->controller_name = substr($this->controller_name, 0, -10);
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ abstract class ControllerCore
|
|||||||
|
|
||||||
protected $redirect_after = null;
|
protected $redirect_after = null;
|
||||||
|
|
||||||
|
public $controller_type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check that the controller is available for the current user/visitor
|
* check that the controller is available for the current user/visitor
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ class FrontControllerCore extends Controller
|
|||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
$this->controller_type = 'front';
|
||||||
|
|
||||||
global $useSSL;
|
global $useSSL;
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|||||||
@@ -34,9 +34,11 @@ abstract class ModuleAdminControllerCore extends AdminController
|
|||||||
* @var Module
|
* @var Module
|
||||||
*/
|
*/
|
||||||
public $module;
|
public $module;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
$this->controller_type = 'moduleadmin';
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$tab = new Tab($this->id);
|
$tab = new Tab($this->id);
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ class ModuleFrontControllerCore extends FrontController
|
|||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
$this->controller_type = 'modulefront';
|
||||||
|
|
||||||
$this->module = Module::getInstanceByName(Tools::getValue('module'));
|
$this->module = Module::getInstanceByName(Tools::getValue('module'));
|
||||||
if (!$this->module->active)
|
if (!$this->module->active)
|
||||||
Tools::redirect('index');
|
Tools::redirect('index');
|
||||||
|
|||||||
@@ -440,7 +440,8 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Hook::exec('actionProductAdd', array('product' => $product));
|
Hook::exec('actionProductAdd', array('product' => $product));
|
||||||
Search::indexation(false, $product->id);
|
if (in_array($product->visibility, array('both', 'search')))
|
||||||
|
Search::indexation(false, $product->id);
|
||||||
$this->redirect_after = self::$currentIndex.(Tools::getIsset('id_category') ? '&id_category='.(int)Tools::getValue('id_category') : '').'&conf=19&token='.($token ? $token : $this->token);
|
$this->redirect_after = self::$currentIndex.(Tools::getIsset('id_category') ? '&id_category='.(int)Tools::getValue('id_category') : '').'&conf=19&token='.($token ? $token : $this->token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1436,7 +1437,8 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Hook::exec('actionProductAdd', array('product' => $this->object));
|
Hook::exec('actionProductAdd', array('product' => $this->object));
|
||||||
Search::indexation(false, $this->object->id);
|
if (in_array($this->object->visibility, array('both', 'search')))
|
||||||
|
Search::indexation(false, $this->object->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the product is virtual, set out_of_stock = 1 (allow sales when out of stock)
|
// If the product is virtual, set out_of_stock = 1 (allow sales when out of stock)
|
||||||
@@ -1505,7 +1507,8 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
{
|
{
|
||||||
$this->_removeTaxFromEcotax();
|
$this->_removeTaxFromEcotax();
|
||||||
$this->copyFromPost($object, $this->table);
|
$this->copyFromPost($object, $this->table);
|
||||||
|
$object->indexed = 0;
|
||||||
|
|
||||||
if ($object->update())
|
if ($object->update())
|
||||||
{
|
{
|
||||||
$this->addCarriers();
|
$this->addCarriers();
|
||||||
@@ -1529,7 +1532,8 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
elseif (empty($this->errors))
|
elseif (empty($this->errors))
|
||||||
{
|
{
|
||||||
Hook::exec('actionProductUpdate', array('product' => $object));
|
Hook::exec('actionProductUpdate', array('product' => $object));
|
||||||
Search::indexation(false, $object->id);
|
if (in_array($object->visibility, array('both', 'search')))
|
||||||
|
Search::indexation(false, $object->id);
|
||||||
|
|
||||||
// Save and preview
|
// Save and preview
|
||||||
if (Tools::isSubmit('submitAddProductAndPreview'))
|
if (Tools::isSubmit('submitAddProductAndPreview'))
|
||||||
|
|||||||
@@ -1366,6 +1366,7 @@ CREATE TABLE `PREFIX_product` (
|
|||||||
`condition` ENUM('new', 'used', 'refurbished') NOT NULL DEFAULT 'new',
|
`condition` ENUM('new', 'used', 'refurbished') NOT NULL DEFAULT 'new',
|
||||||
`show_price` tinyint(1) NOT NULL default '1',
|
`show_price` tinyint(1) NOT NULL default '1',
|
||||||
`indexed` tinyint(1) NOT NULL default '0',
|
`indexed` tinyint(1) NOT NULL default '0',
|
||||||
|
`visibility` ENUM('both', 'catalog', 'search', 'none') NOT NULL default 'both',
|
||||||
`cache_is_pack` tinyint(1) NOT NULL default '0',
|
`cache_is_pack` tinyint(1) NOT NULL default '0',
|
||||||
`cache_has_attachments` tinyint(1) NOT NULL default '0',
|
`cache_has_attachments` tinyint(1) NOT NULL default '0',
|
||||||
`is_virtual` tinyint(1) NOT NULL default '0',
|
`is_virtual` tinyint(1) NOT NULL default '0',
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
SET NAMES 'utf8';
|
||||||
|
|
||||||
|
ALTER TABLE `PREFIX_product` ADD `visibility` ENUM('both', 'catalog', 'search', 'none') NOT NULL default 'both' AFTER `indexed`;
|
||||||
|
|
||||||
|
|
||||||
Reference in new issue
Block a user