Page 1 of 1
Hide products from everywhere, accessible via the URL only
Posted: Mon Sep 24, 2018 6:14 pm
by storiqax
Hello everyone,
I want to somehow hide products that are out of stock, discontinued etc from everywhere (categories, brands, tags...) and make them accessible only from the URL.
I have read many suggestions to remove them from categories but there also the tags, the brand page and the most difficult part is to find where the the product have been related to other products. I don't want to delete them because there always a possibility to make them available again and I do not want to insert them again or going to all of them and re-add the category, brand etc.
Someone told be to put the stock value to -1 but that does nothing at all
Is there any good way to do that?
I think a good way is to disable them but then is not accessible with the URL. Can somehow the disabled products could be accessible via the URL?
Thanks in advance!
Re: Hide products from everywhere, accessible via URL
Posted: Mon Sep 24, 2018 7:14 pm
by paulfeakins
storiqax wrote: ↑Mon Sep 24, 2018 6:14 pm
Can somehow the disabled products could be accessible via the URL?
Why do you want that?
People will find them from Google ...
Re: Hide products from everywhere, accessible via URL
Posted: Mon Sep 24, 2018 7:19 pm
by uksitebuilder
Haven't tested this, but certainly it's possible.
The way I would do it would be as follows:
In the product controller, check that the requested URL is for a product view page (e.g. test for the existence of $this->route and that it contains 'product/product')
If it exists append a variable to the getProduct model call eg.
$product_info = $this->model_catalog _product->getProduct($product_id, true);
// notice the added 'true' boolean added to the model call
Then in the catalog product model file, append a variable to the getProduct method:
public function getProduct($product_id, $product_url = false)
// notice the added default parameter in the getProduct method '$product_url = false'
Finally, we can modify the sql statement to allow products if $product_url is set to true
Near the end of the sql statement, find and replace:
AND p.status = 1
with:
AND (p.status = 1 OR $product_url)
--
As I said, I have not tested this, but in theory it should work unless I have missed something
Re: Hide products from everywhere, accessible via URL
Posted: Mon Sep 24, 2018 7:26 pm
by storiqax
paulfeakins wrote: ↑Mon Sep 24, 2018 7:14 pm
storiqax wrote: ↑Mon Sep 24, 2018 6:14 pm
Can somehow the disabled products could be accessible via the URL?
Why do you want that?
People will find them from Google ...
Well, they have to be blocked from Google and other search engines as well then.
I want to do it because I have read that you should never delete products from an eCommerce site. They said you have to made them "invisible" for better SEO and only accessible from the URL which may be have been shared to social medias etc.
Re: Hide products from everywhere, accessible via URL
Posted: Mon Sep 24, 2018 7:50 pm
by straightlight
storiqax wrote: ↑Mon Sep 24, 2018 7:26 pm
paulfeakins wrote: ↑Mon Sep 24, 2018 7:14 pm
storiqax wrote: ↑Mon Sep 24, 2018 6:14 pm
Can somehow the disabled products could be accessible via the URL?
Why do you want that?
People will find them from Google ...
Well, they have to be blocked from Google and other search engines as well then.
I want to do it because I have read that you should never delete products from an eCommerce site. They said you have to made them "invisible" for better SEO and only accessible from the URL which may be have been shared to social medias etc.
While the statement is true about not removing products from eCommerce web sites, they should neither be invisible but rather active with a stock level of 0. The SEO can still provide positive results afterwards.
Re: Hide products from everywhere, accessible via URL
Posted: Mon Sep 24, 2018 8:03 pm
by storiqax
straightlight wrote: ↑Mon Sep 24, 2018 7:50 pm
While the statement is true about not removing products from eCommerce web sites, they should neither be invisible but rather active with a stock level of 0. The SEO can still provide positive results afterwards.
This should work only for products that is out of stock but I want a solution too for discontinued products, especially if there is a lot of them.
I want the products to be accessible via the URL but hidden from the entire website (expect admin of course).
@uksitebuilder I will give it a try. I'm newbie though and I do not think I have much hope to made it work.
Re: Hide products from everywhere, accessible via the URL only
Posted: Mon Sep 24, 2018 9:17 pm
by olahmyde
Two ways of doing this.....
1.) Disable product from status (Although it would no longer be accessed by link again, only the admin can see it)
2.) Remove product from all categories its under and also its related products, change its model to a totally different thing so it still can't be accessed via models... (pretty sure this should work fine)
Re: Hide products from everywhere, accessible via the URL only
Posted: Mon Sep 24, 2018 10:05 pm
by storiqax
olahmyde wrote: ↑Mon Sep 24, 2018 9:17 pm
Two ways of doing this.....
1.) Disable product from status (Although it would no longer be accessed by link again, only the admin can see it)
2.) Remove product from all categories its under and also its related products, change its model to a totally different thing so it still can't be accessed via models... (pretty sure this should work fine)
You know the "problem" with the first one, so...
What do you mean by models? This is a solution but it is bad for a lot of products, and as I said
I don't want to delete them because there always a possibility to make them available again and I do not want to insert them again or going to all of them and re-add the category, brand etc.
The best way will be to set the stock to -1 for example and the code that listing the products to bypass the negative values.
That's what I am looking for.
Re: Hide products from everywhere, accessible via the URL only
Posted: Wed Sep 26, 2018 7:18 am
by olahmyde
storiqax wrote: ↑Mon Sep 24, 2018 10:05 pm
olahmyde wrote: ↑Mon Sep 24, 2018 9:17 pm
Two ways of doing this.....
1.) Disable product from status (Although it would no longer be accessed by link again, only the admin can see it)
2.) Remove product from all categories its under and also its related products, change its model to a totally different thing so it still can't be accessed via models... (pretty sure this should work fine)
You know the "problem" with the first one, so...
What do you mean by models? This is a solution but it is bad for a lot of products, and as I said
I don't want to delete them because there always a possibility to make them available again and I do not want to insert them again or going to all of them and re-add the category, brand etc.
The best way will be to set the stock to -1 for example and the code that listing the products to bypass the negative values.
That's what I am looking for.
It doesnt delete, it only removes from the page... or try this extension... might help
https://www.opencart.com/index.php?rout ... ing&page=3
Re: Hide products from everywhere, accessible via the URL only
Posted: Wed Sep 26, 2018 9:58 pm
by storiqax
Interesting extension. I'm probably gonna tweak it a little to do what I want.
Thank you!
Re: Hide products from everywhere, accessible via the URL only
Posted: Fri Sep 28, 2018 5:32 pm
by storiqax
So, I tried this extension and it's working fine on a testing installation of OpenCart (even if I tweak it how I want).
The problem is when I tried it to main site. I am getting the following errors:

Could anyone please help?
Re: Hide products from everywhere, accessible via the URL only
Posted: Sat Sep 29, 2018 12:48 am
by storiqax
So...
The extension is working fine with the template I'm using with the default OpenCart database. Not with mine though. Anyone have a clue what's is going on?
I am not able to find any solution

Re: Hide products from everywhere, accessible via the URL only
Posted: Sat Sep 29, 2018 4:20 am
by straightlight
Contact the extension developer to resolved this issue.
Re: Hide products from everywhere, accessible via the URL only
Posted: Sat Sep 29, 2018 6:19 am
by storiqax
straightlight wrote: ↑Sat Sep 29, 2018 4:20 am
Contact the extension developer to resolved this issue.
I will, hope he/she is able to help me.
Re: Hide products from everywhere, accessible via the URL only
Posted: Fri Oct 09, 2020 4:11 am
by Van Quyen
If you use Journal Theme... hope this helps you. Product quantity settings at the product admin page "-1"
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>Hide Product for Quantity "-1"</name>
<id>Hide Product for Quantity "-1"</id>
<code>hide-product-quantity-1</code>
<version>1.0</version>
<author>ZZZZZZ</author>
<link>www.opencart.com</link>
<file path="catalog/model/journal3/product.php">
<operation>
<search><![CDATA[
p.status = '1'
]]></search>
<add position="replace"><![CDATA[
p.status = '1' AND p.quantity > '-1'
]]>
</add>
</operation>
</file>
</modification>