5 replies [Last post]
humanchimp's picture
Offline
Joined: 08/04/2008
Juice: 7
Was this information Helpful?

Hello good people.

I have had all sorts of fun with Ubercart lately, not the least trivial being QuickBooks integration (for any of you who haven't tried this yet, it is a little tricky) and now I am trying to get a lot of inventory items imported using the importer. We have a catalog of over 6,000 products, so I am trying to do a small test run preparatory to running the whole thing.

Curiously, the Importer dies with a fatal error:

PHP Fatal error:  Call to a member function data() on a non-object in /home/thorn/www/sites/all/modules/ubercart/uc_importer/uc_importer.module on line 984, referer: http://[[masked]]\

This is the batch of products I am sending through:

<?xml version="1.0" encoding="UTF-8"?>
<store>
  <products>
    <product>
      <id>1000</id>
      <type>product</type>
      <model>65665656</model>
      <name><![CDATA[Consultation Return]]></name>
      <description></description>
      <sell_price>0.00</sell_price>
    </product>
    <product>
      <id>1001</id>
      <type>product</type>
      <model>5555558976</model>
      <name><![CDATA[mesh tray small]]></name>
      <description></description>
      <sell_price>1.00</sell_price>
    </product>
    <product>
      <id>1002</id>
      <type>product</type>
      <model>566565656</model>
      <name><![CDATA[Tray 50  round units]]></name>
      <description></description>
      <sell_price>1.00</sell_price>
    </product>
    <product>
      <id>1003</id>
      <type>product</type>
      <model>98789877</model>
      <name><![CDATA[Tray #804 32 units 8pack 4cell]]></name>
      <description></description>
      <sell_price>1.00</sell_price>
    </product>
    <product>
      <id>1004</id>
      <type>product</type>
      <model>8767896554</model>
      <name><![CDATA[Tray #38 38 round units]]></name>
      <description></description>
      <sell_price>1.00</sell_price>
    </product>
    <product>
      <id>1005</id>
      <type>product</type>
      <model>16073511558</model>
      <name><![CDATA[Smackers-chocolate/spirulina]]></name>
      <description></description>
      <sell_price>1.49</sell_price>
    </product>
    <product>
      <id>1006</id>
      <type>product</type>
      <model>16073511541</model>
      <name><![CDATA[Smackers-chocolate/almond]]></name>
      <description></description>
      <sell_price>1.49</sell_price>
    </product>
        <product>
      <id>1007</id>
      <type>product</type>
      <model>16073511534</model>
      <name><![CDATA[Smackers-chocolate/peanut]]></name>
      <description></description>
      <sell_price>1.49</sell_price>
    </product>
        <product>
      <id>1008</id>
      <type>product</type>
      <model>34343434</model>
      <name><![CDATA[Tray flat w/hole thermoformed ]]></name>
      <description></description>
      <sell_price>1.50</sell_price>
    </product>
        <product>
      <id>1009</id>
      <type>product</type>

      <model>555556259</model>
      <name><![CDATA[Cilantro 6 pack Og.]]></name>
      <description></description>
      <sell_price>1.75</sell_price>
    </product>
  </products>
</store>

I have written a little kludge to map the columns from a database to an XML file. I see no reason to include that here.

Pray tell, what am I doing wrong?

Thanks,
Christopher

seutje's picture
Offline
Joined: 05/15/2008
Juice: 36
I think ur tag is the

I think ur store tag is the problem
try changing it into

<store xmlns="http://www.ubercart.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ubercart.org http://www.ubercart.org/files/store.xsd">

also (even though I'm not sure if this is mandatory), since ur getting it all from a database table, u should consider either getting a unique hash out of ur database or u should generate one

hope this solves ur problems

here be the end!

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: UC Importer Fatal Error: Call to undefined function

I've never used CDATA with the XML converter in the importer, and I doubt it would actually work. Whatever you use to create the XML should convert ', ", and & characters into their entities.

seutje's picture
Offline
Joined: 05/15/2008
Juice: 36
Re: Re: UC Importer Fatal Error: Call to undefined function

I don't think that is the problem

I intentionally tried not to change my ampersant into an & amp; and it still works

btw, my client also had like 8000 products to add, which they all had stored in an excel file

so I worked out this lil php function to load a CSV version of that excel file and spit out a proper-looking XML file that gets parsed properly by uc_importer

here be the end!

humanchimp's picture
Offline
Joined: 08/04/2008
Juice: 7
Re: Re: Re: UC Importer Fatal Error: Call to undefined function

Thanks for your replies. I have made the changes that each of you suggested. First, I changed the store tag to the one in the example provided. Then Ubercart threw a slightly different error:

PHP Fatal error:  Call to a member function data() on a non-object in /home/thorn/www/sites/all/modules/ubercart/uc_importer/uc_importer.module on line 1030

Note that instead of Ubercart throwing the error at line number 984, it is throwing it at line 1030. I have not modified that file in any way, just the XML I'm sending in.

Then, I removed the CDATA sections, substituting XML entities instead, and generating an md5 hash value for each unique_hash node. Now the error is on yet another line: 1025.

Here is my XML for the small test import:

<?xml version="1.0" encoding="UTF-8"?>
<store xmlns="http://www.ubercart.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ubercart.org http://www.ubercart.org/files/store.xsd">
  <products>
    <product>
      <id>1000</id>
      <unique_hash>fd591d5ca864d44b1a407d1fc721448a</unique_hash>
      <type>product</type>
      <model>5555558976</model>
      <name>mesh tray small</name>
      <sell_price>1.00</sell_price>
    </product>
    <product>
      <id>1001</id>
      <unique_hash>91b9f86df4303fa2221a3ab02a96444f</unique_hash>
      <type>product</type>
      <model>566565656</model>
      <name>Tray 50  round units</name>
      <sell_price>1.00</sell_price>
    </product>
    <product>
      <id>1002</id>
      <unique_hash>aa2846cc5923cb2ca2c54cf79c0f6f47</unique_hash>
      <type>product</type>
      <model>98789877</model>
      <name>Tray #804 32 units 8pack 4cell</name>
      <sell_price>1.00</sell_price>
    </product>
    <product>
      <id>1003</id>
      <unique_hash>d7e21fbecf80f970315da50e3216ad67</unique_hash>
      <type>product</type>
      <model>8767896554</model>
      <name>Tray #38 38 round units</name>
      <sell_price>1.00</sell_price>
    </product>
    <product>
      <id>1004</id>
      <unique_hash>e5b9c03d4a7c400c3a6678b0f0f5932d</unique_hash>
      <type>product</type>
      <model>16073511558</model>
      <name>Smackers-chocolate/spirulina</name>
      <sell_price>1.49</sell_price>
    </product>
  </products>
</store>

I appreciate any tips.

Thanks,
Chris

humanchimp's picture
Offline
Joined: 08/04/2008
Juice: 7
Re: Re: Re: Re: UC Importer Fatal Error: Call to undefined funct

I figured this out. It was a simple matter of including elements for non-required fields. Thanks for all your help.