Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
public function getAccessories($id_lang, $active = true, Context $context = null)
{
$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_.'accessory`
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)$this->id.
($active ? ' AND product_shop.`active` = 1 AND product_shop.`visibility` != \'none\'' : '').'
ORDER BY product_shop.`price` != 0 DESC, stock.`quantity` != 0 DESC';
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 $this->getProductsProperties($id_lang, $result);
}
ты не вполне понимаешь "откуда ноги растут"...надо, каких товаров нет в наличии, те чтобы были в конце...
if (version_compare(_PS_VERSION_, '1.6.1', '>=') === true)
if($order_by=='cp.position'){
$order_by = 'product_shop.`price` != 0 DESC, stock.`quantity` != 0 DESC';
$order_way = '';
}
if($order_by=='cp.position'){
$order_by = 'product_shop.`price` != 0 DESC, stock.`quantity` != 0 DESC';
$order_way = '';
}
Ну так будь добр, подскажи что делал то и как решил проблему?!Разобрался сам.
А как вы это сделали? Помогите плизРазобрался сам.
if ($random === true) {
$sql .= ' ORDER BY RAND() LIMIT '.(int)$random_number_products;
} else {
$sql .= ' ORDER BY qq DESC, pl.name desc,'.(!empty($order_by_prefix) ? $order_by_prefix.'.' : '').'`'.bqSQL($order_by).'` '.pSQL($order_way).'
LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n;
}
Жирным выделил изменения. Сортировка по наличию и алфавиту. Если по алфавиту не нужно, то удали это: pl.name desc, Проверено на ps 1.6.1.4$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) AS quantity, if(stock.quantity=0 , 0, 1) AS qq'.(Combination::isFeatureActive() ? ', IFNULL(product_attribute_shop.id_product_attribute, 0) AS id_product_attribute,