No OC version posted. However, this is an interesting request … if there are no extensions from the Marketplace already doing this, perhaps an experimental code would be great to use in this case …
In catalog/model/catalog/product.php file,
find all instances of:
add above each:
Then, replace all instances of:
with:
This should also find results into the order voucher's table.
In catalog/model/catalog/product.php file,
find all instances of:
Code: Select all
$sql .= " LEFT JOIN " . DB_PREFIX . "product_description pd
Code: Select all
$sql .= " LEFT JOIN `" . DB_PREFIX . "order_product` `op` ON (`op`.`product_id` = `p`.`product_id`) LEFT JOIN `" . DB_PREFIX . "order_voucher` `ov` ON (`ov`.`order_id` = `op`.`order_id`)";
Code: Select all
$sql .= " 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) WHERE 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
$sql .= " 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) WHERE 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') . "' AND `pd`.`product_id` = `op`.`product_id`";
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Unlikely, since the vouchers are order based while the products also represents the services being provided to customers and users.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
This one wouldn't be experimental but more of a concept-introduction. In your catalog/model/catalog folder, create a new model file called: voucher.php .
Then, in your catalog/controller/common/header.php file,
find:
add below:
Then, in your catalog/language/<your_language_code>/common/header.php file,
add at the bottom:
Then, in your catalog/view/theme/<your_theme>/template/common/header.tpl file, add your voucher link and text where you want it to show.
Then, from your catalog/controller/common folder, you could create a new controller called: voucher.php and return your voucher contents with all the related products with your catalog/view/theme/<your_theme>/template/common/voucher.tpl file that you'd also need to create for your designed presentation.
Code: Select all
<?php
class ModelCatalogVoucher extends Model {
public function getVouchers() {
$sql = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_product` `op` INNER JOIN `" . DB_PREFIX . "voucher` `v` ON (`v`.`order_id` = `op`.`order_id`)");
$product_data = array();
$query = $this->db->query($sql);
$this->load->model('catalog/product');
foreach ($query->rows as $result) {
$product_data[$result['product_id']] = $this->model_catalog_product->getProduct($result['product_id']);
}
return $product_data;
}
}
find:
Code: Select all
$data['search'] = $this->load->controller('common/search');
Code: Select all
$data['voucher'] = $this->url->link('common/voucher');
$data['text_voucher'] = $this->language->get('text_voucher');
add at the bottom:
Code: Select all
$_['text_voucher'] = 'Vouchers';
Then, from your catalog/controller/common folder, you could create a new controller called: voucher.php and return your voucher contents with all the related products with your catalog/view/theme/<your_theme>/template/common/voucher.tpl file that you'd also need to create for your designed presentation.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
The new model code has been modified for better performance on the above.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Who is online
Users browsing this forum: Bing [Bot] and 70 guests