I found a thread to display it in the category listing but that method doesnt work when i try to call the image on the product page.
Im using opencart version 1.4.9.3
thanks
there r 3 steps.(Backup your system before.)
1. edit this file
Code: Select all
\catalog\model\catalog\product.php
find public function getProduct($product_id) {.........} and replace to this code.
Code: Select all
public function getProduct($product_id) {
$query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer,m.image AS mimage, ss.name AS stock FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) LEFT JOIN " . DB_PREFIX . "stock_status ss ON (p.stock_status_id = ss.stock_status_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.date_available <= NOW() AND p.status = '1'");
return $query->row;
}
SAVE.
2.Edit
Code: Select all
\catalog\controller\product\product.php
find this line
Code: Select all
$this->data['popup'] = $this->model_tool_image->resize($image, $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
Code: Select all
if ($product_info['mimage']) {
$mimage = $product_info['mimage'];
} else {
$mimage = 'no_image.jpg';
}
$this->data['mthumb'] = $this->model_tool_image->resize($mimage, 120, 120);
3.edit your product.tpl and put this code to anywhere that u want to dispaly a image.
Code: Select all
<img src="<?php echo $mthumb;?>" title="<?php echo $manufacturer; ?>" alt="<?php echo $manufacturer; ?>" />
ร้านค้าออนไลน์
OpenCart Thailand Support Forum
How to Upgrade oc1.5 to 2.0.1.1
Upgrading OpenCart From v.1.4 or v.1.5 to V.2.2 Step by step
But I'm not sure I know what code to replace in step 1.
My code looks in this file looks like so...find public function getProduct($product_id) {.........} and replace to this code.
Code: Select all
public function getProduct($product_id) {
if ($this->customer->isLogged()) {
$customer_group_id = $this->customer->getCustomerGroupId();
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
$query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$customer_group_id . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$customer_group_id . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special, (SELECT points FROM " . DB_PREFIX . "product_reward pr WHERE pr.product_id = p.product_id AND customer_group_id = '" . (int)$customer_group_id . "') AS reward, (SELECT ss.name FROM " . DB_PREFIX . "stock_status ss WHERE ss.stock_status_id = p.stock_status_id AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "') AS stock_status, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r2 WHERE r2.product_id = p.product_id AND r2.status = '1' GROUP BY r2.product_id) AS reviews FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
if ($query->num_rows) {
return array(
...
I am using 1.5 and the coding seems quite different but this is exactly what I need to accomplish.
If I replace the code with what amdev posted in 1.5. The manufacturer image shows up, but I get a whole other wack of problems & errors.
I am trying to replace
Code: Select all
public function getProduct($product_id) {
if ($this->customer->isLogged()) {
$customer_group_id = $this->customer->getCustomerGroupId();
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
$query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, m.image AS mimage, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$customer_group_id . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$customer_group_id . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special, (SELECT points FROM " . DB_PREFIX . "product_reward pr WHERE pr.product_id = p.product_id AND customer_group_id = '" . (int)$customer_group_id . "') AS reward, (SELECT ss.name FROM " . DB_PREFIX . "stock_status ss WHERE ss.stock_status_id = p.stock_status_id AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "') AS stock_status, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r2 WHERE r2.product_id = p.product_id AND r2.status = '1' GROUP BY r2.product_id) AS reviews FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
Code: Select all
[quote]public function getProduct($product_id) {
$query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer,m.image AS mimage, ss.name AS stock FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) LEFT JOIN " . DB_PREFIX . "stock_status ss ON (p.stock_status_id = ss.stock_status_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.date_available <= NOW() AND p.status = '1'");
return $query->row;[/quote]
Notice: Undefined index: reward in /Applications/MAMP/htdocs/loco-wholesale/catalog/controller/product/product.php on line 182Notice: Undefined index: special in /Applications/MAMP/htdocs/loco-wholesale/catalog/controller/product/product.php on line 235Notice: Undefined index: special in /Applications/MAMP/htdocs/loco-wholesale/catalog/controller/product/product.php on line 242Notice: Undefined index: reviews in /Applications/MAMP/htdocs/loco-wholesale/catalog/controller/product/product.php on line 303Notice: Undefined index: rating in /Applications/MAMP/htdocs/loco-wholesale/catalog/controller/product/product.php on line 304
for 15x(I'm tested with 1.5.1.2 SVN At revision: 515 it's work fine.)
1. edit \catalog\model\catalog\product.php
add m.image AS mimage to SELECT command.
Code: Select all
public function getProduct($product_id) {
$query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer,m.image AS mimage,....
Code: Select all
'mimage' => $query->row['mimage'],
Code: Select all
'manufacturer' => $query->row['manufacturer'],
find this line(about line 193).
Code: Select all
$this->load->model('tool/image');
Code: Select all
$this->data['mimage'] = $this->model_tool_image->resize($product_info['mimage'],150,150);
Code: Select all
<img src="<?php echo $mimage; ?>" alt="blah blah blah" />
Goodluck guys.
ร้านค้าออนไลน์
OpenCart Thailand Support Forum
How to Upgrade oc1.5 to 2.0.1.1
Upgrading OpenCart From v.1.4 or v.1.5 to V.2.2 Step by step
This is what i need, I don't know if it worked on 1.5.0.5, I'll try and report the result,
Thanks...
GOLDEN LEOPARD SYSTEM SOLUTION
An ICT System Solution Company in Vietnam
Website: Store: http://opencart.goleo.vn or http://www.opencart.com/index.php?route ... rname=alin
It worked fine on 1.5.0.5,
I have tried to do this for some some hour but can not make it work, now thanks to this topic, it worked
I applied this for latest and product detail also,
This is result http://www.goleo.vn
Thanks so much.
GOLDEN LEOPARD SYSTEM SOLUTION
An ICT System Solution Company in Vietnam
Website: Store: http://opencart.goleo.vn or http://www.opencart.com/index.php?route ... rname=alin
Exactly where do I put this within the function?
In the same function add this code.
Code: Select all
'mimage' => $query->row['mimage'],
after.
Code: Select all
'manufacturer' => $query->row['manufacturer'],
Code: Select all
public function getProduct($product_id) {
if ($this->customer->isLogged()) {
$customer_group_id = $this->customer->getCustomerGroupId();
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
$query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, m.image AS mimage, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$customer_group_id . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$customer_group_id . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special, (SELECT points FROM " . DB_PREFIX . "product_reward pr WHERE pr.product_id = p.product_id AND customer_group_id = '" . (int)$customer_group_id . "') AS reward, (SELECT ss.name FROM " . DB_PREFIX . "stock_status ss WHERE ss.stock_status_id = p.stock_status_id AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "') AS stock_status, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r2 WHERE r2.product_id = p.product_id AND r2.status = '1' GROUP BY r2.product_id) AS reviews, p.sort_order FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
if ($query->num_rows) {
$query->row['price'] = ($query->row['discount'] ? $query->row['discount'] : $query->row['price']);
$query->row['rating'] = (int)$query->row['rating'];
return $query->row;
} else {
return false;
}
}
J
Version 1.5.1.3
I get
Code: Select all
<img src alt >
I did miss out the second part of Step 1 as suggested but it appears that makes it not work.
Anyone any ideas
thank you
I would like to use it to the modules if it is possible?
(bestseller, featured etc...)
can you tell me how?
thanks
amdev wrote: ...
1. edit \catalog\model\catalog\product.php
add m.image AS mimage to SELECT command.In the same function add this code.Code: Select all
public function getProduct($product_id) { $query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer,m.image AS mimage,....
after.Code: Select all
'mimage' => $query->row['mimage'],
2.edit \catalog\controller\product\product.phpCode: Select all
'manufacturer' => $query->row['manufacturer'],
find this line(about line 193).
add this code after.Code: Select all
$this->load->model('tool/image');
3.edit your product.tpl and put this code to anywhere that u want to dispaly a image.Code: Select all
$this->data['mimage'] = $this->model_tool_image->resize($product_info['mimage'],150,150);
Code: Select all
<img src="<?php echo $mimage; ?>" alt="<?php echo $manufacturer; ?>" align="right" border="1px"/>
- OpenCart : Version 1.5.5.1
- Hébergeur : OVH
- Template installé : green_electronic (modifié)
- PHP : ....
- vqmod : 2.3.2
- Site : http://moto-dynozor.com
Users browsing this forum: No registered users and 105 guests