Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Минимальная цена товара в категории


Recommended Posts

Version 2.3

Не могу вывести мин. цену товара из подкатегорий в главную - там где названия подкатегорий.

Делаю следующие 


public function getMinPriceFromCategory($category_id)
        $sql = 'SELECT MIN(' . DB_PREFIX . 'product.price) FROM ' . DB_PREFIX . 'product LEFT JOIN ' .
            DB_PREFIX . 'product_to_category ON ' . DB_PREFIX . 'product.product_id = ' .
            DB_PREFIX . 'product_to_category.product_id WHERE ' . DB_PREFIX . 'product_to_category.category_id = ' . (int)$category_id;

        $query = $this->db->query($sql);
        $price = $query->row['MIN(' . DB_PREFIX . 'product.price)'];

        if ($price != null)
            return $this->currency->format($price); else
            return 0;


После $data['categories'][] = array(

'min_price' => $this->model_catalog_product->getMinPriceFromCategory($result['category_id']),

И в /catalog/view/theme/шаблон/template/product/

<?php echo $min_price; ?>

Итог - : Undefined variable: min_price in  

Не получается - что не так?

Link to comment
Share on other sites

1 минуту назад, Djeff78 сказал:

SELECT MIN(' . DB_PREFIX . 'product.price)

а скидки, акции?


1 минуту назад, Djeff78 сказал:

<?php echo $min_price; ?>


  • +1 1
Link to comment
Share on other sites

ужс... мало того что половина логики не используется... какие-то костыли....псевдонимы...

Edited by n3bo
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.