Witam
Potrzebuje poprawić część kodu którzy działa obecnie źle.
Otóż nie pokazuje podstron z produktami po modyfikacji tego zapytania:
<?php
$select = $db->select()->from(array('t' => DB_PREFIX
. 'prod_translations'), array('options', 'product_name', 'description'))->join(array('p' => DB_PREFIX
. 'products'), 'p.product_id = t.pid', array('product_id', 'category_id', 'gfx', 'vat', 'promo', 'weight', 'in_stock', 'price', 'actual_price' =>
'IF(s.special_price, s.special_price, p.price)'))->joinLeft(array('g' => DB_PREFIX
. 'gfx'), 't.pid = g.prod_id AND g.main_gfx = 1', array('unic_name'))-> joinLeft
(array('s' => DB_PREFIX
. 'special_offers'), ' AND s.date_to >= ' . strtotime(date("Y-m-d")), array('special_price'))->where('t.lang = ?', $session->lang)->where('t.active = 1')->limit($krok, $page * $krok);
?>
na to:
<?php
$select = $db->select()->from(array('t' => DB_PREFIX
. 'prod_translations'), array('options', 'product_name', 'description'))->join(array('p' => DB_PREFIX
. 'products'), 'p.product_id = t.pid', array('product_id', 'category_id', 'gfx', 'vat', 'promo', 'weight', 'in_stock', 'price', 'actual_price' =>
'IF(s.special_price, s.special_price, p.price)'))->joinLeft(array('g' => DB_PREFIX
. 'gfx'), 't.pid = g.prod_id AND g.main_gfx = 1', array('unic_name'))-> joinLeft
(array('m' => DB_PREFIX
. 'manufacturers'), 'p.producer_id = m.producent_id', array('name'))-> joinLeft
(array('s' => DB_PREFIX
. 'special_offers'), ' AND s.date_to >= ' . strtotime(date("Y-m-d")), array('special_price'))->where('t.lang = ?', $session->lang)->where('t.active = 1')->group('m.name')->limit($krok, $page * $krok);
?>
chciałem po prostu pogrupować według producenta,
kod do obliczenia ilości podstron itp jest taki:
<?php
// pobranie ilosci produktow;
$select->reset(Zend_Db_Select::COLUMNS)->reset(Zend_Db_Select::LIMIT_COUNT)->
reset(Zend_Db_Select
::LIMIT_OFFSET)->reset(Zend_Db_Select
::ORDER);
// $select->from(null, array('ile' => 'count( product_id )'));
$select->from(null, array('ile' => 'count( producer_id )'));
$hash = md5((string
)$select); $resIleStron = $cache->load('productlist_select_num_' . $hash);
if ($resIleStron === false)
{
$resIleStron = $select->query()->fetch();
$cache->save($resIleStron, 'productlist_select_num_' . $hash, array('product')); }
$smarty->assign('filter_producer_found', true);
$ile_stron = ceil($resIleStron["ile"] / $krok); ?>
Będę wdzięczny za pomoc.
Pozdrawiam