Categories Exported ID Number Not Label?

  • Posts: 35
  • Thank you received: 1
10 years 4 months ago #161809

url of the page with the problem -- : goldsmiths.accountsupport.com
-- HikaShop version -- : HikaShop Business: 2.3.0
-- Joomla version -- : 3.3.0
-- PHP version -- : 5.3.13
-- Browser(s) name and version -- : all
-- Error-message(debug-mod must be tuned on) -- : none


Hello,

I have an issue with the export feature and am wondering if there is anything that can be done about it.

Basically the client needs to export all the products each month and merge it with new products and then import again. And everything would be fine except that there are issues with the way the "categories" column data gets exported from HikaShop.

The bigger issue is that the categories I have set up have several sub categories that are the exact same name, Example:

Fine Jewelry -> Gold -> Rings
Fine Jewelry -> Silver -> Rings
Fine Jewelry -> Colored Jem -> Rings

As you can see the third level deep categories are all labeled "Rings".

When setting up the import file I found that having categories labeled the same, for whatever reason screws up where the products get designated into categories when performing a product import using the category labels.

However, I did find that using the category ID numbers works well and so I have been setting up the import file with category id numbers instead of labels. The only problem with this is that when you do a product export the export file produces the categories column as labels and not category ID numbers.

In addition to making monthly mass changes to the products and performing a product import monthly, the client needs the ability to make small tweaks to products from he back-end. Which ultimately renders the last import file used inaccurate. So the need to export the products each month becomes crucial in their workflow. But as I mentioned the export file becomes an even larger confusing task becuase unless they change the "Categories" column in the newly exported file to reflect ID numbers, when they go to import, all the products will get placed in wrong categories.

Is there a way to alter the export functionality so it outputs the category ID numbers, instead of the category labels?


Thank you for your time!

Sincerely,
Brandon Cardone, Card One Concepts

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
10 years 4 months ago #161959

Hi,

Yes, it's quite easy to change.
Edit the file "export" of the view "product" via the menu Display>Views for your backend template and change the line:

$categories[] = str_replace(array('"',',',';'), array('""','\\,','\\;'), $this->categories[$category]->category_name);
to:
$categories[] = str_replace(array('"',',',';'), array('""','\\,','\\;'), $this->categories[$category]->category_id);

The following user(s) said Thank You: CardOneConcepts

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

  • Posts: 35
  • Thank you received: 1
10 years 4 months ago #161976

Thank you so much Nicolas,

That certainly was easy!

So, I have a second part question to the export file. I was wondering if it can be solved with a tweak to the export code as well?

Basically after exporting and opening the file the first 50 lines have the category structure in them as shown in the attached screenshot. I am not really sure what this information is in the export file for becuase when you try to import those lines output errors? Perhaps it is there for adding new categories? But that will not be necessary for my situation becuase new categories will always be added manually from the back-end and then translated as category ID numbers in the import file.

It is certainly easy enough to just delete those lines in the exported spreadsheet file, but is there a way to alter the view code so it does not output this information in the export file so that when the file is opened the products start on line 2 and the category structure is not present in the file?

i ask becuase if I can remove a step for my client when they are exporting and working with the files that would be great!

Thank you for your time again!


Thank you for your time!

Sincerely,
Brandon Cardone, Card One Concepts
Attachments:
Last edit: 10 years 4 months ago by CardOneConcepts.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
10 years 4 months ago #162022

Hi,

That's indeed to insert the category tree to the website so in your case you don't need that in your export.

It's actually also quite easy to remove from the export view file.
Just delete the code below in the product/export.php file :

if(!empty($this->categories)) {
	foreach($this->categories as $category) {
		$data = array();
		for($i = 0; $i < $product_table_count; $i++)
			$data[] = '';
		if(!empty($category->category_parent_id) && isset($this->categories[$category->category_parent_id]))
			$data[] = $this->categories[$category->category_parent_id]->category_name;
		else
			$data[] = '';
		if(!empty($category->file_path))
			 $data[] = $category->file_path;
		else
			$data[] = '';

		$data[] = $category->category_name;
		for($i = 0; $i < $after_category_count; $i++)
			$data[] = '';
		$export->writeline($data);
	}
}

The following user(s) said Thank You: CardOneConcepts

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

  • Posts: 35
  • Thank you received: 1
10 years 4 months ago #162126

Thank you again Nicolas!!!

That did the trick!


Thank you for your time!

Sincerely,
Brandon Cardone, Card One Concepts

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

Time to create page: 0.061 seconds
Powered by Kunena Forum