Post by lukeketchum1 » Mon Jul 16, 2018 8:52 pm

Hello all,

Is there any easy way to disassociate all products from a certain category? [OPENCART 3.]

For example I have products in cat1/subcat/subcat2, cat1/subcat/ and cat1

I would like to remove them from cat1 and subcat, and leave them only in subcat2. So I would like to essentially select 100 products, and disassociate them from 2 of the 3 categories that they belong to.

Would this be some sort of SQL thing? or is there a way to do it in the opencart interface without doing it one by one (I have a few thousand products added to store now)

Please let me know, thank you

Luke

Active Member

Posts

Joined
Tue Jan 23, 2018 12:30 am

Post by IP_CAM » Tue Jul 17, 2018 5:17 am

Well, do you see the same Product, but placed in Main- and Sub-Category ?
And, if so, the just about only way, to avoid such, would be so-called SEO Linking
throughout the Site, by use of an extension, by example like one linked below.
Ernie
---
Ultimate Links Module manager Block - OpenCart 2.X
https://www.opencart.com/index.php?rout ... n_id=26418
Ultimate Links Module manager Block - OpenCart 3.X
https://www.opencart.com/index.php?rout ... n_id=31942
---
found here:
https://www.opencart.com/index.php?rout ... le%20links
---

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by shahriar-b » Tue Jul 17, 2018 11:26 am

You don't have to buy an extension to do this easy task, unfortunately on this forum everyone trying to make money!
you can simply write a query to remove all products from certain category only:

Code: Select all

delete from oc_product_to_category where category_id=999;
change the category_id by the category_id you want to disconnect your products from.

Newbie

Posts

Joined
Sat Feb 03, 2018 11:18 am

Post by IP_CAM » Tue Jul 17, 2018 5:58 pm

on this forum everyone trying to make money!
Well, that might be you opinion, still, during my stay in this place,
nobody ever had to pay a single penny to me. :D
On the other hand, if you really care to assist others for free, then
better take into account, that most won't even know, what a QUERY is. :laugh:
But you will find out, I assume, that OC-Life is not as easy, as it might sound.
Good Luck ! ::)
Ernie

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by lukeketchum1 » Tue Jul 17, 2018 6:14 pm

Thanks both for your replies.

shahriar-b - I can confirm that worked really nicely, its done - much appreciated.

Luke

Active Member

Posts

Joined
Tue Jan 23, 2018 12:30 am

Post by IP_CAM » Thu Jul 19, 2018 4:02 am

Well, more by accident, I found two free Extensions, possibly coming close.
It might not save you from a lot of work, but it could solve your category
linking-problem for good.
Good Luck ;)
Ernie
---
Structured Data Unspecified Type & URL Without Category(vq)
Google-Translation:
It is an add-on that helps SEO configuration by solving the following issues.
- Fixes an unspecified type error in Google Structured Data Testing Tool results,
resulting from OpenCG's enriched card creation code for Facebook.
This will ensure that Google receives your structural data without error.

- Corrects the error that our product pages have two different URLs, which again
caused our site to be detected incorrectly. If we open the products under the
category page, it prevents the category name from being added to the URL.
In this case, our product page comes with the link added directly to the root URL.
https://www.opencart.com/index.php?rout ... n_id=32399
---
Remove parent category urls from subcategories and products
How to Remove parent category urls from subcategories and products
domain.com/category/sub-category = domain.com/sub-category
domain.com/category/product.html = domain.com/product.html
https://www.opencart.com/index.php?rout ... n_id=33577
---

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by digiscrap » Fri Aug 28, 2020 3:13 pm

shahriar-b wrote:
Tue Jul 17, 2018 11:26 am
You don't have to buy an extension to do this easy task, unfortunately on this forum everyone trying to make money!
you can simply write a query to remove all products from certain category only:

Code: Select all

delete from oc_product_to_category where category_id=999;
change the category_id by the category_id you want to disconnect your products from.
Thanks, I was looking for this. Can this be done inside Opencart or in phpMyAdmin ?

Newbie

Posts

Joined
Wed Jun 19, 2019 7:57 pm

Post by thekrotek » Fri Aug 28, 2020 4:14 pm

digiscrap wrote:
Fri Aug 28, 2020 3:13 pm
Thanks, I was looking for this. Can this be done inside Opencart or in phpMyAdmin ?
PHPMyAdmin only.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by phat64mower » Tue May 18, 2021 7:36 pm

Hi,

I have run the query and it works although I have a question.
It deletes the product from the specific category, however the product still remains active on the store without a category.
What I would like it to do is completely delete the product from the site.

Any thoughts?

Thanks
shahriar-b wrote:
Tue Jul 17, 2018 11:26 am
You don't have to buy an extension to do this easy task, unfortunately on this forum everyone trying to make money!
you can simply write a query to remove all products from certain category only:

Code: Select all

delete from oc_product_to_category where category_id=999;
change the category_id by the category_id you want to disconnect your products from.

Newbie

Posts

Joined
Fri Jan 09, 2015 9:30 pm

Post by thekrotek » Tue May 18, 2021 11:29 pm

Product data is saved in different tables: options, attributes, description etc. You mush delete products from all these tables.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by phat64mower » Tue May 18, 2021 11:38 pm

Hi,

So could I use the same principle

delete from oc_product_to_category where category_id=999;

eg:

delete from oc_product_attribute where category_id=999;
and so on...

making sure I get all the oc_product tables?

Thanks Alot!
thekrotek wrote:
Tue May 18, 2021 11:29 pm
Product data is saved in different tables: options, attributes, description etc. You mush delete products from all these tables.

Newbie

Posts

Joined
Fri Jan 09, 2015 9:30 pm

Post by thekrotek » Wed May 19, 2021 12:38 am

Nope. You will have to use JOIN to delete products properly. And if you already removed category from products and don't have a list of these products, then... well, you're fudged.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by phat64mower » Wed May 19, 2021 4:38 pm

Hi,

Thanks for your reply. Liking the fudged comment.
Luckily I havent done that. Just doing some testing at the moment.

Please could you give me an example of a query required to delete a product using JOIN.

Thanks
thekrotek wrote:
Wed May 19, 2021 12:38 am
Nope. You will have to use JOIN to delete products properly. And if you already removed category from products and don't have a list of these products, then... well, you're fudged.

Newbie

Posts

Joined
Fri Jan 09, 2015 9:30 pm
Who is online

Users browsing this forum: No registered users and 254 guests