Products after deleting categories

  • Posts: 59
  • Thank you received: 0
13 years 6 months ago #1532

A question for you.

If i delete a category with products inside... what happen after that to the products? Are they deleted too?

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

  • Posts: 81677
  • Thank you received: 13100
  • MODERATOR
13 years 6 months ago #1533

The products aren't deleted. However, the link with this category is removed.
I looked at the code and there seems to be an error there. Right now if you do so, a proper link to the root category won't be created automatically and you won't be able to see the product in the listing. You should change the code

$query = 'SELECT category_id FROM '.hikashop::table('category').' WHERE category_parent_id=0 AND category_type=\'product\' LIMIT 1';
					$this->database->setQuery($query);
					$root = $this->database->loadResult();
to
$root = 'product';
					$this->getMainElement($root);
in the file administrator/components/com_hikashop/classes/category.php near line 260. That way, a new link will be automatically created to your main "product category" for all the products which had only a one link to the category you deleted.
Another solution would be to add another category in the products before deleting the category. The link to the deleted category will be removed but the link to the other category will still be there and no additional link will be added.

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

  • Posts: 59
  • Thank you received: 0
13 years 6 months ago #1545

Sorry, but after editing the file, those products are still dissappeared.

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

  • Posts: 81677
  • Thank you received: 13100
  • MODERATOR
13 years 6 months ago #1547

Don't you see them under the main product category ?

I tried on my end with the modification I told you and it worked for me.

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

  • Posts: 59
  • Thank you received: 0
13 years 6 months ago #1548

Sorry, but noyhing appears. No matter what filter configuration I use.

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

  • Posts: 59
  • Thank you received: 0
13 years 6 months ago #1549

The behaviour after editing that php is as you described. Products are relinked to another category, but the products that dissappeared at category deleting at previous to php edition have been lost.

Curiously, if i look for those products through joomla search engine, they still are there, but nothing appears at the backend.

May you upload that php file in order to download and try it?

Also, i´d like to know how to set a main "product category" for all the products, i am not sure what are you talking about.

Last edit: 13 years 6 months ago by Avaray.

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

  • Posts: 81677
  • Thank you received: 13100
  • MODERATOR
13 years 6 months ago #1559

Yes, the products already deleted before changing the code won't appear in the back end as they need to be linked to a category for that, but their data is still there. The only way to have them back will be to go in your database and change some data. In the table hikashop_product_category, in the column product_id search for the id of your missing product. If you find an entry with a category_id which is 0, change the category_id to the id of the category you want it under. If you don't see any entry for your product, you have to create a new one for it.
Then you will see your product again on the back end.

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

  • Posts: 81677
  • Thank you received: 13100
  • MODERATOR
13 years 6 months ago #1567

Ah, something I didn't think of. You could try to edit a product and in the URL change the cid value to the id of the product you want to edit.

For example, if the missing product has the product_id 5. You could edit another product and replace &cid=2 (if 2 is the id of the other product) by &cid=5 and you will be able to edit the product and add another category to it so that it's again visible in the listing.

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

  • Posts: 59
  • Thank you received: 0
13 years 6 months ago #1572

Too late :).

I do not need those products anymore, they were only testing products. I want to erase all my previous products in order to create new ones.

I tried to delete the product entries in database. I am not any kind of database nor squl expertise, but i tried erase them using common sense and your previous indications.

I proceeded this way:
- at hikashop_product_category: i listed all entries in product_id field and deleted them.
- at hikashop_product: i listed all entries in product_id field and also deleted them.

As a result, now all those testing products has dissappeared from searching results, but now i got an empty product in my backend with a curious behaviour: i can´t delete it and if i try to edit it, a new product is created with those new settings and this blank products remains.

I guess that i need to delete something more, but i do not know what.

Last edit: 13 years 6 months ago by Avaray.

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

  • Posts: 81677
  • Thank you received: 13100
  • MODERATOR
13 years 6 months ago #1573

Maybe you had variants on those products ? If so, you will also have to delete the variant entries (in hikashop_product search on the column product_parent_id for the id of your deleted products).

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

  • Posts: 59
  • Thank you received: 0
13 years 6 months ago #1576

Yes, one of those products has variants.
I deleted entries at hikashop_product on product paren_id and at hikashop_variant on variant_product_id.
The blank product still remains.
¿Could i send you the sql file? I am sure you have further analysis capabilities to discover what´s happenning.

Attachments:

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

  • Posts: 81677
  • Thank you received: 13100
  • MODERATOR
13 years 6 months ago #1577

It's easy to find the culprit. Select the product and click on the edit button. On the edit page of the ghost product, if you put your mouse over the title "Products" you should see in the URL displayed at the bottom of your browser the id of that product. Then, you just have to search for that id in the product table and remove it.

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

  • Posts: 59
  • Thank you received: 0
13 years 6 months ago #1578

As you say, the url says "product_id=o".
But if i go to hikashop_product, product_id, there is nothing inside. No entries.
I created a new product to check it, and this new product appears, but nothing with id=o.

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

  • Posts: 81677
  • Thank you received: 13100
  • MODERATOR
13 years 6 months ago #1579

ah, I think I know. You must have an entry in hikashop_product_category with a product_id to 0. You should remove it.

Last edit: 13 years 6 months ago by nicolas.

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

  • Posts: 59
  • Thank you received: 0
13 years 6 months ago #1580

Sorry, but there is nothing related to products in "hikashop_category".

The only two options related to id are "category_id" and "category_parent_id".

The only one with an entry marked with id=0 it´s "category_parent_id".

Attachments:

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

  • Posts: 81677
  • Thank you received: 13100
  • MODERATOR
13 years 6 months ago #1581

I wanted to say hikashop_product_category.

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

  • Posts: 59
  • Thank you received: 0
13 years 6 months ago #1582

There was only a product there, but despite the url link said that id=0, this product had id´s different from 0. After deleting it, ghost product has been erased. I am not sure about what happened, but now the ghost one it´s gone.

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

  • Posts: 81677
  • Thank you received: 13100
  • MODERATOR
13 years 6 months ago #1583

Ah ok the link wasn't pointing to any product. That's indeed an alternative to the problem :)
Glad you found it.

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

Time to create page: 0.073 seconds
Powered by Kunena Forum