在产品的选项卡中,有一个产品类别-香水-瓶容量的选择。例如50ml-10 $,100 ml-13 $。如何在产品卡和价格类别中显示:10-12 $? 我只是坚决做到这一点。 catalog / model / catalog / product.php
public function getProductPrices($product_id) {
$prices = array();
$query = $this->db->query("SELECT COUNT(product_id) AS total_option, MIN(price) AS min_price, MAX(price) AS max_price FROM " . DB_PREFIX . "product_option_value WHERE product_id = ". (int) $product_id);
if($query->row && $query->row['total_option'] > 1) {
$prices = array(
'min_price' => $query->row['min_price'],
'max_price' => $query->row['max_price']
);
}
return $prices;
}
catalog / product / category.php 代替
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')))
此
$prices = $this->model_catalog_product->getProductPrices($result['product_id']);
if($prices) {
$min_price = $this->currency->format($prices['min_price']);
$max_price = $this->currency->format($prices['max_price']);
$price = 'от'. $min_price .'до'. $max_price;
} else {
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
}
但是它不起作用,我有500个错误