Jump to content
Sign in to follow this  
Djeff78

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

Recommended Posts

Version 2.3

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

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

/catalog/model/catalog/product.php

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;
    }

/catalog/controller/product/category.php

После $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  

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

Share this post


Link to post
Share on other sites
1 минуту назад, Djeff78 сказал:

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

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

 

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

<?php echo $min_price; ?>

$category['min_price'];

  • +1 1

Share this post


Link to post
Share on other sites
7 минут назад, thentru сказал:

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

 

$category['min_price'];

Спасибо - вывел.

 

Share this post


Link to post
Share on other sites

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

Edited by n3bo

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

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.