Post by xtr3mx7 » Wed Sep 07, 2011 9:48 am

Hello guys,

Is that possible to add a new page (from the top menu) to Opencart 1.4.9.5 like "offer of the month" for promotional offers that would take place for a particular month?

I am aware of "specials" but I am not keen to use it unless the "specials" do have a page from the menu.

Any help would be much appreciated.

Thanks a lot in advance :)
Last edited by xtr3mx7 on Fri Sep 23, 2011 9:46 pm, edited 1 time in total.

New member

Posts

Joined
Mon Jul 13, 2009 1:02 am

Post by xtr3mx7 » Wed Sep 21, 2011 11:37 am

little update: I have successfully created a module from the featured module.

I tried to route it through the index.php so that I can call it from a new URL that can be added to the menu, but there's always this error indicating that such page is not found.

Is there any possible way to do that?

Any help would be much appreciated.

Thanks.

New member

Posts

Joined
Mon Jul 13, 2009 1:02 am

Post by xtr3mx7 » Fri Sep 23, 2011 9:47 pm

I have successfully solved it myself by duplicating common/home.php to common/offer.php and added the module offer to offer_home.

Cheers.

New member

Posts

Joined
Mon Jul 13, 2009 1:02 am

Post by karadev » Sat Sep 24, 2011 12:08 am

hi friend, can you explain how to do it for version 1.5.1.1 / 2 OC :)
http://elitps.karadev.net/ - test address

http://www.karadev.net
http://www.webshop.karadev.net


User avatar
New member

Posts

Joined
Mon Nov 29, 2010 9:31 pm
Location - Varna, Bulgaria

Post by theo » Sat Sep 24, 2011 8:39 pm

Hi xtr3mx7 can you explain a little more what you did, a step by step because we have monthly offers as well and would like to integrate something like on the first page of the shop

New member

Posts

Joined
Thu Sep 22, 2011 3:35 pm

Post by karadev » Sun Sep 25, 2011 12:34 am

hi, this is great but and also what will happen in version 1.5.1.1 / 2 because this is the last version of the OC and now use it to test address razgeldah page for additives not found such a module or help make this

http://www.karadev.net
http://www.webshop.karadev.net


User avatar
New member

Posts

Joined
Mon Nov 29, 2010 9:31 pm
Location - Varna, Bulgaria

Post by xtr3mx7 » Wed Oct 12, 2011 4:37 pm

Hello theo,

Sorry for the late reply.

The steps 1-6 below are to ensure that you can add a new URL link and page to opencart as "offer"

1. Make a copy of catalog/controller/common/home.php (e.g., catalog/controller/common/offer.php)
2. Edit new offer.php (replacing 'home' to 'offer')
3. Make a copy of catalog/language/english/common/home.php (e.g., catalog/language/english/common/offer.php
4. Edit new offer.php (changing the text associated to '$_['text_latest']')
5. Make a copy of catalog/view/theme/your template/template/common/home.tpl (e.g., catalog/view/theme/your template/template/common/offer.tpl)
6. Edit your header.tpl to include this

Code: Select all

<li><a href="<?php echo str_replace('&', '&', $offer); ?>" id="tab_offer" style="color: #ff0000"><?php echo $text_offer; ?></a></li>
Now step 7 to 13:

7. Make a copy of catalog/controller/module/featured.php (e.g., catalog/controller/module/offer.php)
8. Edit new offer.php (replacing 'featured' to 'offer')
9. Make a copy of catalog/language/english/module/featured.php (e.g., catalog/language/english/module/offer.php
10. Edit new offer.php (changing the text associated to '$_['heading_title']', e.g., to "offer of the month")
11. Make a copy of catalog/view/theme/your template/template/module/featured_home.tpl (e.g., catalog/view/theme/your template/template/module/offer_home.tpl)
12. Go to dashboard>extensions>modules
13. Enable your newly created module

Do not forgot to edit catalog/model/catalog/product.php.

Find:

Code: Select all

public function getFeaturedProducts($limit) {
		$product_data = $this->cache->get('product.featured.' . $this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $limit);

		if (!$product_data) { 
			$query = $this->db->query("SELECT *, pd.name AS name, p.image, m.name AS manufacturer, ss.name AS stock, (SELECT AVG(r.rating) FROM " . DB_PREFIX . "review r WHERE p.product_id = r.product_id GROUP BY r.product_id) AS rating FROM " . DB_PREFIX . "product_featured f LEFT JOIN " . DB_PREFIX . "product p ON (f.product_id=p.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (f.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.status = '1' AND p.date_available <= NOW() 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') . "' ORDER BY p.date_added ASC LIMIT " . (int)$limit); //original code "' ORDER BY p.sort_order ASC LIMIT " . (int)$limit);
	
			$product_data = $query->rows;

			$this->cache->set('product.featured.' . $this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $limit, $product_data);
		}
		
		return $product_data;
	}
Add BEFORE:

Code: Select all

	//Offer of the Month
	public function getOfferProducts($limit) {
		$product_data = $this->cache->get('product.Offer.' . $this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $limit);

		if (!$product_data) { 
			$query = $this->db->query("SELECT *, pd.name AS name, p.image, m.name AS manufacturer, ss.name AS stock, (SELECT AVG(r.rating) FROM " . DB_PREFIX . "review r WHERE p.product_id = r.product_id GROUP BY r.product_id) AS rating FROM " . DB_PREFIX . "product_offer f LEFT JOIN " . DB_PREFIX . "product p ON (f.product_id=p.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (f.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.status = '1' AND p.date_available <= NOW() 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') . "' ORDER BY p.sort_order ASC LIMIT " . (int)$limit);
	
			$product_data = $query->rows;

			$this->cache->set('product.Offer.' . $this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $limit, $product_data);
		}
		
		return $product_data;
	}
Now you just have to alter your database for the new module.
1. Go to phpmyadmin and select your opencart database
2. Create a table "product_offer" with 1 field "product_id"

To test if everything is fine, go to dashboard>extensions>modules>offer and edit. Add some products and selection position "offer"

You should see on your home page a new menu has appeared in red "offer of the month".

You can change the color of the menu to whatever you want.

Hope this helps getting your "offer of the month page" :)

Cheers.

New member

Posts

Joined
Mon Jul 13, 2009 1:02 am

Post by theo » Thu Oct 13, 2011 5:43 pm

Many Thanks for the complete listing on how to do this xtr3mx7, I am currently still going through the data entry bit which is a mare but as soon as I have done that I will get this bit done.

New member

Posts

Joined
Thu Sep 22, 2011 3:35 pm
Who is online

Users browsing this forum: Google [Bot] and 352 guests