Add the status of product availability to the category opencart
Display the status of the presence of goods in the list of goods
πŸ’Ό Creation of modern websites of any complexity. | πŸ‘Œ WEB-UKRAINE.COM

Add the status of product availability to the category opencart

5/54 ratings

Hello dear friends.

In this article, I would like to describe several different ways and manipulations on products that are not available in opencart.

  1. Add status of availability to category
  2. The product of which is not available at the very end of the list
  3. Hide the goods which are not in stock

Task β„–1

First of all, let's talk about how to display (display) the availability of goods in the list of products in categories and similar pages such as search, stocks, manufacturers, etc.

By default, Opencart does not display the status of the availability of goods in the general list of products, well, let's fix it.

And so before us there is opencart version 1.5.5.1 or any other version of this branch, well, we will use the template by default.

In order to display the availability of goods in the category, do the following:

1.To a file /catalog/language/russian/product/category.php

In any place we add:

I added this line after ($_['text_manufacturer'] = 'Manufacturer:';) But this is not a principle and you can leave it anywhere, between tags <?php and ?> Also do not forget to do the same with other language files if you have a store in several languages.

The text we added, now we need to correct a bit of the controller itself namely:

2. In file catalog/controller/product/category.php

After the line:

Adding:

Everything with the controller is also finished.

3. Well, our last step is to display all this construction in the file of our template :

Namely, we open:
catalog/view/theme/default/template/product/category.tpl
And in the right place you add the code:

I added it immediately under the price namely before the last div after the code:

That's all, in such a simple way we added to the list of products the display of its availability, as all this looks like you can see in the photo below.


Task β„–2

Now we proceed to consider the second question, sometimes we still need to do so that the product of which is not available was always at the very end of the list of goods.

The solution of this task is even easier, open the file catalog\model\catalog\product.php And change the code in it:

To the following code:

All, now all products in which the quantity indicated 0 will be displayed at the very end of the list of all products of the category.


Task β„–3

I am often asked how you can remove products that are not available from the OpenCart product list, but that they are available for search engines.

That is, the problem is that users would not visually see such goods, but that they could go to them by direct links, because it's a pity to remove the goods completely from the store because they could be indexed by search engines, and there is no traffic on them , Sometimes even very good traffic, of course the client who will go to this link to your site will not buy it because it is not available, but it can be bought from you by any other product that is available in the warehouse.

And so let's consider how all the same you can hide the missing goods from the category, but leave them to access by direct link.

And the solution as always is very simple, we find the file catalog/controller/product/category.php

And before the line:

Add the following:

Well and it is obligatory after a line:

We close the bracket, that is, add:

That's basically all, now when viewing the list of products in the category the user will not see the goods in which the value of the quantity is zero.
But the product will be available to users who come to you from search engines. In this revision there is one not significant minus, the amount of general goods in the category will be displayed all, as well as goods in stock and goods which are not available, but I think that this is not a significant minus.

Well, that's all I wanted to describe here. I will be glad if this note will be useful to someone!

You may also like

No Comment

You can post first response comment.

Leave a Reply

Π’ΠΈΠ±Π΅Ρ€Ρ–Ρ‚ΡŒ спосіб спілкування
Звязатися Π· Π½Π°ΠΌΠΈ!
Ми Π³ΠΎΡ‚ΠΎΠ²Ρ– Π΄ΠΎ Π΄Ρ–Π°Π»ΠΎΠ³Ρƒ.