Search code examples
phpsqlebay-api

eBay API SKU missing from response


I am trying to download all my listings from ebay into my database using following code:

$client = new eBaySOAP($session);
$ebay_items_array = array();
try {
    $client = new eBaySOAP($session);

    $params = array(
        'Version' => $Version,
        'GranularityLevel' => "Fine",
        'OutputSelector' => "ItemID,SKU,Title",
        'EndTimeFrom' => date("c", mktime(date("H"), date("i")+10, date("s"), date("n"), date("j"), date("Y"))),
        'EndTimeTo' => date("c", mktime(date("H"), date("i"), date("s"), date("n"), date("j")+120, date("Y"))),
                            'Pagination' => array(
                    'PageNumber' => $_GET['linkebaynum'],
                    'EntriesPerPage' => "20"
                    )
        );
    $results = $client->GetSellerList($params);
    if($results->Ack == "Success")
    {
    $c = 0;
        if(is_array($results->ItemArray->Item))
        {
            foreach($results->ItemArray->Item as $key => $value)
            {

                array_push($ebay_items_array, $value->ItemID);

          $Qcheck = tep_db_query('select ebay_productstoitems_items_id from ' . TABLE_EBAY_PRODUCTS_TO_ITEMS . ' where ebay_productstoitems_items_id = ' . $value->ItemID);

              $check = tep_db_fetch_array($Qcheck);
              if($check == 0) {
              if($check['ebay_productstoitems_items_id'] = $value->ItemID) { 
              echo 'Not in Database - Inserting ' . $value->ItemID . '<br>';
              tep_db_query("insert ebay_productstoitems set ebay_productstoitems_items_id = '" . $value->ItemID . "'");
           }
           }else{
          echo 'Found  - ' . $value->ItemID . ' Nothing to Change<br>';
          tep_db_query("update ebay_productstoitems set ebay_productstoitems_items_id = '" . $value->ItemID . "' where ebay_productstoitems_items_id = '" . $value->ItemID . "'");
          }
            }
            $c++;
        }
    }

} catch (SOAPFault $f) {
    print "error<br>";
}

print "Request:<br>".ebay_formatxmlstring($client->__getLastRequest())."<br><br>";
print "Response:<br>".ebay_formatxmlstring($client->__getLastResponse())."<br><br>";

But it will not recover the SKU (or CustomLabel). Can anyone explain what I am missing to get the SKU into the database along with the ItemID.

Or would I have to recover lists of ItemID and then do a second call to recover the SKU or CustomLabel?


Solution

  • Found out what the problem was the Sandbox does not appear to pass the SKU back. I switched to the live site and hey presto the SKU is being retrieved along with the Itemid.