Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 3 additions & 21 deletions component/site/models/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -798,29 +798,11 @@ protected function populateState($ordering = '', $direction = '')
$selectedTemplate,
'int'
);
$this->setState('category_template', $categoryTemplate);

if ($_POST) {
$manufacturerId = $app->input->post->getInt('manufacturer_id', 0);

if ($manufacturerId != $app->getUserState(
$this->context . '.manufacturer_id',
$app->input->get->getInt('manufacturer_id', 0)
)) {
$app->redirect(
Redshop\IO\Route::_(
'index.php?option=com_redshop&view=category&layout=' . $layout . '&cid=' . $this->_id . '&manufacturer_id=' . $manufacturerId
. '&Itemid=' . $app->input->getInt('Itemid', 0),
true
)
);
}
} else {
$manufacturerId = $app->input->getInt('manufacturer_id', 0);
$app->setUserState($this->context . '.manufacturer_id', $manufacturerId);
}

$categoryId = $app->input->post->getInt('category_id', 0);
$manufacturerId = $app->input->getInt('manufacturer_id', 0);

$this->setState('category_template', $categoryTemplate);
$this->setState('category_id', $categoryId);
$this->setState('manufacturer_id', $manufacturerId);

Expand Down
51 changes: 50 additions & 1 deletion component/site/models/manufacturers.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,59 @@ public function getManufacturerProducts($template_data = '')
$limitstart = JFactory::getApplication()->input->getInt('limitstart', 0);
$query = $this->_buildProductQuery($template_data);
$this->products = $this->_getList($query, $limitstart, $limit);
$countProduct = count($this->products);
$orderBy = $this->_buildProductOrderBy();

if (strpos($orderBy, "p.product_price ASC") !== false) {
for ($i = 0; $i < $countProduct; $i++) {
$productPrices = RedshopHelperProductPrice::getNetPrice($this->products[$i]->product_id);

$this->products[$i]->productPrice = $productPrices['product_price'];
}

$this->products = $this->columnSort($this->products, 'productPrice', 'ASC');
} elseif (strpos($orderBy, "p.product_price DESC") !== false) {
for ($i = 0; $i < $countProduct; $i++) {
$productPrices = RedshopHelperProductPrice::getNetPrice($this->products[$i]->product_id);

$this->products[$i]->productPrice = $productPrices['product_price'];
}

$this->products = $this->columnSort($this->products, 'productPrice', 'DESC');
}

return $this->products;
}

public function columnSort($unsorted, $column, $sort)
{
$sorted = $unsorted;

if ($sort == "ASC") {
for ($i = 0; $i < count($sorted) - 1; $i++) {
for ($j = 0; $j < count($sorted) - 1 - $i; $j++) {
if ($sorted[$j]->$column > $sorted[$j + 1]->$column) {
$tmp = $sorted[$j];
$sorted[$j] = $sorted[$j + 1];
$sorted[$j + 1] = $tmp;
}
}
}
} else {
for ($i = 0; $i < count($sorted) - 1; $i++) {
for ($j = 0; $j < count($sorted) - 1 - $i; $j++) {
if ($sorted[$j]->$column < $sorted[$j + 1]->$column) {
$tmp = $sorted[$j];
$sorted[$j] = $sorted[$j + 1];
$sorted[$j + 1] = $tmp;
}
}
}
}

return $sorted;
}

public function getProductLimit()
{
return $this->_productlimit;
Expand Down Expand Up @@ -299,7 +348,7 @@ public function _buildProductQuery($template_data = '')
$query->where($db->qn('p.manufacturer_id') . ' IN (' . $shopperGroupManufactures . ')');
}

if ($filterBy != '0') {
if (!empty($filterBy)) {
$query->where($db->qn('c.id') . ' = ' . $db->q((int)$filterBy));
}

Expand Down