how to remove the first category from Google Product Feed

  • Posts: 290
  • Thank you received: 22
1 year 11 months ago #341089

-- HikaShop version -- : 4.5.1
-- Joomla version -- : 4.1.2
-- PHP version -- : 8.0

Hi,
Is it doable to have the first category removed from the product_type field in the Google Product Feed?

Or have some sort of search / replace option for these fields?

I understand this needs some PHP work done by a programmer but I'm just trying to see if it's possible and maybe some tips to get started in the right direction :)

Thanks.

Last edit: 1 year 11 months ago by nico.van.leeuwen. Reason: solved

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
1 year 11 months ago #341093

Hi,

Removing the first category from the product_type should be quite easy for a developer.
In the file plugins/hikashop/google_products.php you have that code:

				foreach($product->categories_id as $catID){
					foreach($category_path as $id=>$catPath){
						if($id == $catID){
							if(strlen($type.str_replace(',', ' ', $catPath['path']).',') > 750) continue;
							$type .= str_replace(',', ' ', $catPath['path']).',';
						}
					}
				}
to skip the first category, you could replace that code by:
				$first = true;
				foreach($product->categories_id as $catID){
					foreach($category_path as $id=>$catPath){
						if($id == $catID){
							if($first) { $first = false; continue; }
							if(strlen($type.str_replace(',', ' ', $catPath['path']).',') > 750) continue;
							$type .= str_replace(',', ' ', $catPath['path']).',';
						}
					}
				}
Now please remember that this file will be overwritten each time you update HikaShop. So you'll loose your changes there and you'll have to redo them.

The following user(s) said Thank You: nico.van.leeuwen

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

Time to create page: 0.050 seconds
Powered by Kunena Forum