Beispiel #1
0
 public function retrieveCategories($params)
 {
     $account_id = $params['AccountID'];
     $this->session->setRequestToken($params['AuthToken']);
     $account = BeanFactory::getBean('xeBayAccounts');
     if ($account->retrieve($account_id) === null) {
         return false;
     }
     $bean = BeanFactory::getBean('xeBayCategories');
     $req = new GetCategoriesRequestType();
     // $req->setLevelLimit(1);
     $req->setDetailLevel("ReturnAll");
     set_time_limit(60 * 10);
     $res = $this->proxy->GetCategories($req);
     $categoryCount = 0;
     if ($this->testValid($res)) {
         $GLOBALS['db']->query("DELETE FROM xebaycategories WHERE xebaycategories.xebayaccount_id = '{$account_id}'");
         $account->category_count = $res->getCategoryCount();
         $account->category_update_time = $res->getUpdateTime();
         $account->category_version = $res->getCategoryVersion();
         $account->reserve_price_allowed = $res->getReservePriceAllowed();
         $account->reduce_reserve_allowed = $res->getReduceReserveAllowed();
         $account->minimum_reserve_price = $res->getMinimumReservePrice();
         $account->save();
         $categoryArray = $res->getCategoryArray();
         foreach ($categoryArray as &$category) {
             $bean->xebayaccount_id = $account_id;
             $bean->autopay_enabled = $category->getAutoPayEnabled();
             $bean->b2bvat_enabled = $category->getB2BVATEnabled();
             $bean->bestoffer_enabled = $category->getBestOfferEnabled();
             $bean->category_id = $category->getCategoryID();
             $bean->category_level = $category->getCategoryLevel();
             $bean->name = $category->getCategoryName();
             $categoryParent = $category->getCategoryParentID();
             if (count($categoryParent) == 1) {
                 $bean->category_parent_id = $category->getCategoryParentID(0);
             } else {
                 echo $bean->name . " has many parents";
                 sugar_cleanup(true);
             }
             $bean->expired = $category->getExpired();
             $bean->intl_autos_fixed_cat = $category->getIntlAutosFixedCat();
             $bean->leaf_category = $category->getLeafCategory();
             $bean->lsd = $category->getLSD();
             $bean->orpa = $category->getORPA();
             $bean->orra = $category->getORRA();
             $bean->seller_guarantee_eligible = $category->getSellerGuaranteeEligible();
             $bean->virtual = $category->getVirtual();
             $bean->id = create_guid();
             $bean->new_with_id = true;
             $bean->save();
         }
         return true;
     } else {
         $this->dumpObject($res);
         return false;
     }
 }
 /**
  * sample_GetCategories::dispatchCall()
  * 
  * Dispatch the call
  *
  * @param array $params array of parameters for the eBay API call
  * 
  * @return boolean success
  */
 public function dispatchCall($params)
 {
     $req = new GetCategoriesRequestType();
     $req->setCategoryParent($params['CategoryParent']);
     $res = $this->proxy->GetCategories($req);
     if ($this->testValid($res)) {
         $this->dumpObject($res);
         return true;
     } else {
         return false;
     }
 }
 /**
  * @return GetCategoriesResponseType
  * @param GetCategoriesRequestType $request 
  */
 function GetCategories($request)
 {
     $request->setVersion(EBAY_WSDL_VERSION);
     return $this->call('GetCategories', $request);
 }
 //run through root list save them and get subcategories
 $comma = "', ";
 $null = "'0', ";
 $rparen = RPAREN;
 $detail_level = 'ReturnAll';
 $insert = INSERT_INTO . TABLE_EBAY_CATEGORIES . " (name, id, parentid, leaf) VALUES (";
 for ($j = 0, $n = count($catRootList); $j < $n; $j++) {
     $mycattype = $catRootList[$j];
     $sqlstring = $insert;
     $sqlstring .= APOS . addslashes($mycattype->getCategoryName()) . $comma;
     $sqlstring .= APOS . $mycattype->getCategoryID() . $comma;
     $sqlstring .= $null;
     $sqlstring .= APOS . $mycattype->getLeafCategory() . APOS . $rparen;
     olc_db_query($sqlstring);
     //subcategories
     $req1 = new GetCategoriesRequestType();
     $req1->DetailLevel = $detail_level;
     $req1->LevelLimit = 255;
     $req1->setCategoryParent($mycattype->getCategoryID());
     $res1 = $cs->GetCategories($req1);
     //get subcategories from api and save them
     $catList = $res1->getCategoryArray();
     for ($k = 1, $m = count($catList); $k < $m; $k++) {
         $mycattype1 = $catList[$k];
         $parentid = $mycattype1->getCategoryParentID();
         $sqlstring_sub = $insert;
         $sqlstring_sub .= APOS . addslashes($mycattype1->getCategoryName()) . $comma;
         $sqlstring_sub .= APOS . $mycattype1->getCategoryID() . $comma;
         $sqlstring_sub .= APOS . $parentid[0] . $comma;
         $sqlstring_sub .= APOS . $mycattype1->getLeafCategory() . APOS . $rparen;
         olc_db_query($sqlstring_sub);