Post by Taurinense » Fri Jun 12, 2020 4:57 pm

Hello everyone!

Is there a way to be able to release all new products except those of a specific category?
I have 9 categories, plus a "special one", which I would like to keep out of the latest products.

Thanks!!

New member

Posts

Joined
Tue May 28, 2019 11:21 pm

Post by straightlight » Fri Jun 12, 2020 6:32 pm

This topic has now been moved to the OpenCart 3.0 Support > General Support section of the forum.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by Taurinense » Sat Jun 13, 2020 7:23 pm

You say there is no way? :(

New member

Posts

Joined
Tue May 28, 2019 11:21 pm

Post by straightlight » Sat Jun 13, 2020 7:58 pm


Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by letxobnav » Sat Jun 13, 2020 9:12 pm

Depends on how sophisticated you want it to be.

Simple if you have the category id of your "special one".

in catalog/model/catalog/product.php

you replace function getLatestProducts from

Code: Select all

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

		if (!$product_data) {
			$query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.date_added DESC LIMIT " . (int)$limit);

			foreach ($query->rows as $result) {
				$product_data[$result['product_id']] = $this->getProduct($result['product_id']);
			}

			$this->cache->set('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data);
		}

		return $product_data;
	}
to:

Code: Select all

	public function getLatestProducts($limit,$exclude_categories = array()) {
		$product_data = $this->cache->get('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit);
		if (!$product_data) {
			if (!empty($exclude_categories)) {
				$exclude = implode(',',$exclude_categories);
				$query = $this->db->query("SELECT distinct(p.product_id) FROM " . DB_PREFIX . "product p LEFT JOIN oc_product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p.product_id = p2c.product_id) WHERE p2c.category_id NOT IN (".$exclude.") AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = 0 ORDER BY p.date_added DESC LIMIT " . (int)$limit);
			} else {
				$query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.date_added DESC LIMIT " . (int)$limit);
			}
			foreach ($query->rows as $result) {
				$product_data[$result['product_id']] = $this->getProduct($result['product_id']);
			}
			$this->cache->set('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data);
		}
		return $product_data;
	}
then you can pass an array containing the category id's for which you wish to exclude the products.

if passing an array is to difficult, simply adjust the function header to:

Code: Select all

public function getLatestProducts($limit,$exclude_categories = array('xx')) {
where xx is the exclude category id or for multiple category ids

Code: Select all

public function getLatestProducts($limit,$exclude_categories = array('xx','yy','zz')) {
mind you, the query results are cached.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by Taurinense » Tue Jun 16, 2020 5:23 pm

Thank you very much for helping! I tried but unfortunately the products of the category in question continue to appear.

Below is the code that I put where you told me, and the screens of the id of the category and the products that come out on the home.

:(

thanks!

Code: Select all

	public function getLatestProducts($limit,$exclude_categories = array('129','142')) {
		$product_data = $this->cache->get('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit);
		if (!$product_data) {
			if (!empty($exclude_categories)) {
				$exclude = implode(',',$exclude_categories);
				$query = $this->db->query("SELECT distinct(p.product_id) FROM " . DB_PREFIX . "product p LEFT JOIN oc_product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p.product_id = p2c.product_id) WHERE p2c.category_id NOT IN (".$exclude.") AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = 0 ORDER BY p.date_added DESC LIMIT " . (int)$limit);
			} else {
				$query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.date_added DESC LIMIT " . (int)$limit);
			}
			foreach ($query->rows as $result) {
				$product_data[$result['product_id']] = $this->getProduct($result['product_id']);
			}
			$this->cache->set('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data);
		}
		return $product_data;
	}

	public function getPopularProducts($limit) {
		$product_data = $this->cache->get('product.popular.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit);
	
		if (!$product_data) {
			$query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.viewed DESC, p.date_added DESC LIMIT " . (int)$limit);
	
			foreach ($query->rows as $result) {
				$product_data[$result['product_id']] = $this->getProduct($result['product_id']);
			}
			
			$this->cache->set('product.popular.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data);
		}
		
		return $product_data;
	}

Attachments

Schermata 2020-06-16 alle 11.22.47.png

Schermata 2020-06-16 alle 11.22.47.png (633.96 KiB) Viewed 1693 times

Schermata 2020-06-16 alle 11.19.25.png

Schermata 2020-06-16 alle 11.19.25.png (43.11 KiB) Viewed 1693 times


New member

Posts

Joined
Tue May 28, 2019 11:21 pm

Post by xxvirusxx » Tue Jun 16, 2020 5:52 pm

You have refreshed Ocmod modification, cleared Theme cache, SASS cache?

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by letxobnav » Tue Jun 16, 2020 6:07 pm

as I said:
mind you, the query results are cached.
so delete the product.latest.* files in your cache directory or save your latest extension module again which should also clear that cache file.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by Taurinense » Tue Jun 16, 2020 6:21 pm

Yes, i delete that file "cache.product.latest.2.0.1.90.1592304394"
I cleared Theme cache, SASS cache, and log, but I can't update in the changes page. always gives me this error

Code: Select all

Notice: Trying to get property of non-object in /home/perlo/domains/turbowaterstyle.com/public_html/new/admin/controller/marketplace/modification.php on line 146Warning: Cannot modify header information - headers already sent by (output started at /home/perlo/domains/turbowaterstyle.com/public_html/new/admin/controller/startup/error.php:34) in /home/perlo/domains/turbowaterstyle.com/public_html/new/system/library/response.php on line 36

Attachments

Schermata 2020-06-16 alle 12.20.40.png

Schermata 2020-06-16 alle 12.20.40.png (66.72 KiB) Viewed 1663 times

Last edited by straightlight on Tue Jun 16, 2020 7:35 pm, edited 1 time in total.
Reason: Added code tags.

New member

Posts

Joined
Tue May 28, 2019 11:21 pm

Post by letxobnav » Tue Jun 16, 2020 7:10 pm

That is a notice, probably some crappy modification you have installed.

check which categories products 1822 & 1823 are in, you need to add them all.
and maybe find a faster host as this is not good.
Capture.JPG

Capture.JPG (235.07 KiB) Viewed 1638 times


Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by Taurinense » Tue Jun 16, 2020 7:33 pm

Ok, thanks for the tip!
I checked, both products 1822 & 1823 are in category ID 129 -> 142.

Damn! ??? ???

Attachments

Schermata 2020-06-16 alle 13.26.39.png

Schermata 2020-06-16 alle 13.26.39.png (44.19 KiB) Viewed 1627 times

Schermata 2020-06-16 alle 13.26.24.png

Schermata 2020-06-16 alle 13.26.24.png (15.63 KiB) Viewed 1627 times


New member

Posts

Joined
Tue May 28, 2019 11:21 pm

Post by xxvirusxx » Tue Jun 16, 2020 7:53 pm

Check if Fastor use another module for Latest.

LE. Module for old version but can easily by converted to 3.x
https://www.opencart.com/index.php?rout ... n_id=23352

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by Taurinense » Tue Jun 16, 2020 10:38 pm

Thanks for the answer xxvirusxx ! could this be?

---> public_html/new/catalog/view/theme/fastor/template/product/product.tpl

Code: Select all

 <?php } elseif($theme_options->get( 'display_text_new' ) != '0' && $theme_options->isLatestProduct( $product_id )) { ?>
     					      	 <div class="new"><?php if($theme_options->get( 'new_text', $config->get( 'config_language_id' ) ) != '') { echo $theme_options->get( 'new_text', $config->get( 'config_language_id' ) ); } else { echo 'New'; } ?></div>
					      	 <?php } ?>
					      	 
					     	 <a href="<?php echo $popup; ?>" title="<?php echo $heading_title; ?>" id="ex1" <?php if($theme_options->get( 'product_image_zoom' ) == 2) { ?>class="popup-image"<?php } else { echo 'class="open-popup-image"'; } ?>><img src="<?php echo $thumb; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" id="image" itemprop="image" data-zoom-image="<?php echo $popup; ?>" /></a>
					      </div>
					  	 <?php } else { ?>
					  	 <div class="product-image">
					  	 	 <img src="image/no_image.jpg" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" id="image" itemprop="image" />
					  	 </div>
					  	 <?php } ?>
				      </div>

New member

Posts

Joined
Tue May 28, 2019 11:21 pm

Post by straightlight » Tue Jun 16, 2020 10:40 pm

Taurinense wrote:
Tue Jun 16, 2020 10:38 pm
Thanks for the answer xxvirusxx ! could this be?

---> public_html/new/catalog/view/theme/fastor/template/product/product.tpl

Code: Select all

 <?php } elseif($theme_options->get( 'display_text_new' ) != '0' && $theme_options->isLatestProduct( $product_id )) { ?>
     					      	 <div class="new"><?php if($theme_options->get( 'new_text', $config->get( 'config_language_id' ) ) != '') { echo $theme_options->get( 'new_text', $config->get( 'config_language_id' ) ); } else { echo 'New'; } ?></div>
					      	 <?php } ?>
					      	 
					     	 <a href="<?php echo $popup; ?>" title="<?php echo $heading_title; ?>" id="ex1" <?php if($theme_options->get( 'product_image_zoom' ) == 2) { ?>class="popup-image"<?php } else { echo 'class="open-popup-image"'; } ?>><img src="<?php echo $thumb; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" id="image" itemprop="image" data-zoom-image="<?php echo $popup; ?>" /></a>
					      </div>
					  	 <?php } else { ?>
					  	 <div class="product-image">
					  	 	 <img src="image/no_image.jpg" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" id="image" itemprop="image" />
					  	 </div>
					  	 <?php } ?>
				      </div>
Unless using an extension, TPL files with OC v3.x releases are not supported by default. Which OC version are you using? You are posting under the OC v3.x releases section of the forum.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by Taurinense » Tue Jun 16, 2020 10:41 pm

OC Version 3.0.2.0

New member

Posts

Joined
Tue May 28, 2019 11:21 pm

Post by straightlight » Tue Jun 16, 2020 10:45 pm

Taurinense wrote:
Tue Jun 16, 2020 10:41 pm
OC Version 3.0.2.0
OC v3.x releases do not use TPL files out-of-the-box.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by Taurinense » Tue Jun 16, 2020 10:53 pm

Okay, maybe I found it. I think I have to modify this string. Could be?

---> public_html/new/catalog/controller/extension/module/filter_product.php

Code: Select all

if($tab['title'] == 'latest' || $tab['title'] == 'special' || $tab['title'] == 'bestsellers' || $tab['title'] == 'category' || $tab['title'] == 'random' || $tab['title'] == 'people_also_bought' || $tab['title'] == 'most_viewed' || $tab['title'] == 'related') {
					if($tab['title'] == 'latest') {
						$data_products = array(
							'sort'  => 'p.date_added',
							'order' => 'DESC',
							'start' => 0,
							'limit' => $setting['limit']
						);

New member

Posts

Joined
Tue May 28, 2019 11:21 pm

Post by Taurinense » Mon Jun 22, 2020 3:16 pm

Hello! why was the topic marked "unsupported"? Can't you make changes to the last php file I published? thank you so much

sorry but I'm new to opencart, and I still don't know how to move ...

Thanks!!!

New member

Posts

Joined
Tue May 28, 2019 11:21 pm

Post by xxvirusxx » Mon Jun 22, 2020 3:31 pm

Taurinense wrote:
Mon Jun 22, 2020 3:16 pm
Hello! why was the topic marked "unsupported"?
Because is about Fastor theme and not Default theme.

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by Taurinense » Mon Jun 22, 2020 7:24 pm

Lk, damn ... I didn't know! Sorry!! :(

that this problem I don't really know how to solve it.

Virus, did you get my pm? thanks and sorry if I disturb you

New member

Posts

Joined
Tue May 28, 2019 11:21 pm
Who is online

Users browsing this forum: No registered users and 12 guests