[英]How to get all products from category with any price in OpenCart?
$data = array(
'filter_category_id' => $category_id,
);
$products = $this->model_catalog_product->getProducts($data);
This is what I use to get all products by category ID. 这是我用于按类别ID获取所有产品的方法。
I am developing a price slider for OpenCart 1.5.6 and I've noticed that whenever I do a query with a selected price range, the method above also gives me results in that price range. 我正在为OpenCart 1.5.6开发一个价格滑块,我注意到每当我使用选定的价格范围进行查询时,上面的方法也会给出我在该价格范围内的结果。
What I need is to get all products from a specific category despite the price every time. 我需要的是尽管价格每次都从特定类别获得。 How do I do this? 我该怎么做呢?
Finally got it working: 终于搞定了:
$products = $this->db->query("
SELECT p.price, ptc.*, ps.price as special
FROM " . DB_PREFIX ."product p
LEFT JOIN " . DB_PREFIX ."product_to_category ptc
ON p.product_id = ptc.product_id
LEFT JOIN " . DB_PREFIX ."product_special ps
ON p.product_id = ps.product_id
WHERE ptc.category_id ='$category_id'")->rows;
Using this query I always get all products from the specific category. 使用此查询,我总是从特定类别中获取所有产品。 (also included few other options to get special price). (还包括一些其他选项以获得特价)。
Hope it will be useful for someone! 希望它对某人有用!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.