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!!
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
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;
}
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;
}
if passing an array is to difficult, simply adjust the function header to:
Code: Select all
public function getLatestProducts($limit,$exclude_categories = array('xx')) {
Code: Select all
public function getLatestProducts($limit,$exclude_categories = array('xx','yy','zz')) {
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.
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 (633.96 KiB) Viewed 1693 times
Schermata 2020-06-16 alle 11.19.25.png (43.11 KiB) Viewed 1693 times
Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer
so delete the product.latest.* files in your cache directory or save your latest extension module again which should also clear that cache file.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.
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 (66.72 KiB) Viewed 1663 times
Reason: Added code tags.
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.
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.
I checked, both products 1822 & 1823 are in category ID 129 -> 142.
Damn!


Attachments
Schermata 2020-06-16 alle 13.26.39.png (44.19 KiB) Viewed 1627 times
Schermata 2020-06-16 alle 13.26.24.png (15.63 KiB) Viewed 1627 times
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
---> 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>
Attachments
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.Taurinense wrote: ↑Tue Jun 16, 2020 10:38 pmThanks 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>
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
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
---> 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']
);
Attachments
sorry but I'm new to opencart, and I still don't know how to move ...
Thanks!!!
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

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
Users browsing this forum: No registered users and 12 guests