5 replies [Last post]
stormer's picture
Offline
Joined: 09/16/2007
Juice: 110
Was this information Helpful?

I'm working my way through an exported xml file in order to set up a large import. However, I've come across this section in the file (exported from 1 product)

<price>0.00</price><weight>0</weight><ordering>0</ordering>
</option></options></attribute></attributes><products><product>
<unique_hash>5eaee8caa7b63e4ebe57ec515de0b1f5</unique_hash>
<id>23</id><type>product</type>

The bit that has me wondering is the "unique_hash" bit - what is this and how should I deal with this when setting up my xml files for import?

many thanks

Ole

psynaptic's picture
Offline
Early adopter... addicted to alphas.Not KulvikTheminator
Joined: 08/28/2007
Juice: 731
Re: What is "unique_hash" in exported xml file?

This is what Lyle says on the unique_hash:

"Yeah, the unique hash is preparation for a module that's to be used for multi-site setups. It would allow you to make a change to a product on one site, and then export that product to the other sites automatically. Because the node ids can be different, Übercart generates the unique_hash when the node is first created, allowing the module to find the right product to change."

There is some discussion about it in this thread. Maybe there is something there that will help you. Sorry for not giving a more direct answer.

Shawn Conn's picture
Offline
Administrator
Joined: 08/07/2007
Juice: 916
Re: What is "unique_hash" in exported xml file?

The unique hash is md5 hash of the product's data (see PHP's md5 function). This is used to give a product a unique key to identify it. For example, the importer will use this to decide if it is importing a product that already exists in the catalog. To give you a working example how to implement this, we used the following line for building the XML that imported products into our true equipment parts site

<?php
...
$xml .= '<unique_hash>'. md5(print_r($product, true)) .'</unique_hash>'."\n";
...
?>

where $product was the array containing the product fields (e.g. $product = array ('model' => 'name of model', 'description' => 'description of product', etc.). See the importing data for more information.

-Shawn Conn: If the Name Don't Rhyme It Ain't Mine

stormer's picture
Offline
Joined: 09/16/2007
Juice: 110
Re: Re: What is "unique_hash" in exported xml file?

So if the system automatically generates this can we leave it out of the XML import doc?

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Re: Re: What is "unique_hash" in exported xml file?

Not necessarily. If you are importing new products, you don't need it, but if you want to replace the products that are there, it's a good idea to include the hash to make sure they match up properly. Product titles aren't necessarily unique, so they are fundamentally unreliable.

stormer's picture
Offline
Joined: 09/16/2007
Juice: 110
Re: Re: Re: Re: What is "unique_hash" in exported xml file?

Excellent, thanks very much. I'm importing new so will leave it out.