URLs still work even though category unpublished

  • Posts: 39
  • Thank you received: 1
8 years 7 months ago #215012

-- HikaShop version -- : 2.3.0
-- Joomla version -- : 3.3
-- PHP version -- : 5.3.24
-- Browser(s) name and version -- : any

We recently noticed that even though a category is UNpublished the associated URL still works and the page still shows up in search engines.

Example: www.destroyallguitars.com/guitars/25-asher

The above page is output from a category that is a child of the "guitars" category. The category itself is Unpublished but the URL to this page still works and search engines still index it. This is a problem because we have dropped that vendor and there is potential for them to complain that search engines are still directing folks to our site for their products, which we currently do not carry.

We need to be able to completely turn off certain categories and have their associated URLs become inactive. Short of deleting categories is there a way to do this? (Note that we do not wish to delete categories as sometimes we need to reinstate them.)

Thank you.

Please Log in or Create an account to join the conversation.

  • Posts: 26007
  • Thank you received: 4004
  • MODERATOR
8 years 7 months ago #215028

Hi,

Yes the category is "available" even if it is unpublished.
The fact is that you can use unpublished categories to list products in a product listing ; that's mostly why there is no check made for the category state.
But we can see to perform that check if the product listing is not displayed in a module.

In the file "components/com_hikashop/views/product/view.html.php" you can replace the code

	$categoryClass = hikashop_get('class.category');
	$element = $categoryClass->get(reset($pageInfo->filter->cid),true);
	$this->assignRef('element', $element);
By
	$categoryClass = hikashop_get('class.category');
	$element = $categoryClass->get(reset($pageInfo->filter->cid),true);
	$this->assignRef('element', $element);
	if(empty($this->module) && (empty($element) || empty($element->category_published))) {
		$element = null;
		return;
	}
It should avoid the display of the listing.
I'll also submit that patch to the rest of the HikaShop team in order to see if we integrate it into the next build or not.
Do not hesitate to give your feedback on the patch.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: PolishedGeek

Please Log in or Create an account to join the conversation.

  • Posts: 39
  • Thank you received: 1
8 years 7 months ago #215248

Looks like we're going to have to update our HikaShop version before trying this. I am unable to find the code you suggested replacing in the file components/com_hikashop/views/product/view.html.php.

We have an update scheduled for next month. Will report back then as to how this works out.

Many thanks!

Please Log in or Create an account to join the conversation.

  • Posts: 73
  • Thank you received: 8
  • Hikaserial Standard Hikashop Business Hikashop Essential
1 year 10 months ago #342167

I realise that this is quite an old post but I couldn't find anything more recent... I have this same problem. We want to temporarily prevent people from buying from certain categories.

If I unpublish the categories, you can still reach either the category pages and product pages with the direct URL. Unpublishing the menu items also doesn't work.

I tried the code above but it just caused an error.

Is there any solutions?

Many thanks.

Please Log in or Create an account to join the conversation.

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
1 year 10 months ago #342170

Hi,

Well, there are several ways to go about it:
1. You could simply use the products listing features:
- use the left explorer to access the category of the products you want to not be available
- change the pagination settings to have all the products of the category on one page
- use the checkbox at the top to select all the products
- click on the unpublish button at the top and all the products of that category will be unpublished at once
And when a product is unpublished, its page won't be available and it will even be removed from the cart if someone already has it in his cart and is trying to go through the checkout. It's even better than the code solution provided by Jerome 7 years ago because this would only remove the products from the listing, and wouldn't prevent the users from accessing directly the product page.

2. Another approach would be to create a mass actions of the data type "category" via the menu System>Mass actions. The published mass action would have:
- a trigger "after a category is updated"
- an action "run MySQL query with the query:

UPDATE #__hikashop_product AS p SET p.product_published = {category_published} WHERE p.product_id IN (SELECT product_id FROM #__hikashop_product_category WHERE category_id = {category_id});
That way, when you would publish/unpublish a category, it would automatically publish/unpublish the corresponding products

3. A cleaner approach would be to develop a plugin which would use the many events in HikaShop to automatically cancel the display of a product page etc after checking the categories. But that's a lot more difficult to do. The advantage of this method, is that you would keep the published state of each product the way it is set in the backend. Because with the previous two methods, unpublished products would be automatically published when you want to reenable a category and vice-versa even if you have products you don't want to change.

Please Log in or Create an account to join the conversation.

  • Posts: 73
  • Thank you received: 8
  • Hikaserial Standard Hikashop Business Hikashop Essential
1 year 10 months ago #342196

Thanks for the reply. 1 and 2 are not really an option as we have lots of unpublished products and we won't be able to tell which was which if we unpublish everything.

We'll manage for now but it would be nice if someone cleverer than me created a plugin! :)

Best wishes
Leila

Please Log in or Create an account to join the conversation.

Time to create page: 0.077 seconds
Powered by Kunena Forum