Post by onyxweb » Tue Sep 18, 2018 12:49 am

Hi,

We have Gift Vouchers enabled - but they are not searchable in the search box.

Hoiw can we make them easier to find?

Thanks,

Bass

New member

Posts

Joined
Fri Mar 19, 2010 6:30 am

Post by straightlight » Tue Sep 18, 2018 1:02 am

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 … :ponder:

In catalog/model/catalog/product.php file,

find all instances of:

Code: Select all

$sql .= " LEFT JOIN " . DB_PREFIX . "product_description pd
add above each:

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`)";
Then, replace all instances of:

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') . "'";				
with:

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`";				
This should also find results into the order voucher's table.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by onyxweb » Tue Sep 18, 2018 1:12 am

Hi,

2.0.2.3

Gosh that's a lot of custom coding - I really appreciate your effort and expertise.

Think this should be native functionality, don't you?

Thanks,

Bass

New member

Posts

Joined
Fri Mar 19, 2010 6:30 am

Post by straightlight » Tue Sep 18, 2018 1:14 am

onyxweb wrote:
Tue Sep 18, 2018 1:12 am
Think this should be native functionality, don't you?
Unlikely, since the vouchers are order based while the products also represents the services being provided to customers and users.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by onyxweb » Tue Sep 18, 2018 1:16 am

In an effort to make them more accessible, is there a way of adding 'Gift Vouchers' to the top nav bar?

New member

Posts

Joined
Fri Mar 19, 2010 6:30 am

Post by straightlight » Tue Sep 18, 2018 1:35 am

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 .

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;
	}
}
Then, in your catalog/controller/common/header.php file,

find:

Code: Select all

$data['search'] = $this->load->controller('common/search');
add below:

Code: Select all

$data['voucher'] = $this->url->link('common/voucher');

$data['text_voucher'] = $this->language->get('text_voucher');
Then, in your catalog/language/<your_language_code>/common/header.php file,

add at the bottom:

Code: Select all

$_['text_voucher'] = 'Vouchers';
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.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Tue Sep 18, 2018 1:52 am

The new model code has been modified for better performance on the above.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by onyxweb » Tue Sep 18, 2018 3:23 am

Wow, again! Thank you so much.

b

New member

Posts

Joined
Fri Mar 19, 2010 6:30 am
Who is online

Users browsing this forum: No registered users and 38 guests