requiem Posted March 13, 2014 Share Posted March 13, 2014 Bonjour, Excellent Module. Cependant , sauf erreur de ma part je n ai rien vu qui concernait le Storefront dans le AddFixedPriceItem ? ce serait bien de voir apparaitre dans la gestion des catégories la récupération des catégories storefront du compte pour affecter en même temps la boutique du client. ça peut se faire rapidement ? ou je développe . mais pas le temps en ce moment moi trop de travail. <?php require_once('./keys.php'); require_once('./eBaySession.php'); class StoreCategories { public $resp; // SimpleXML obj public $responseXml; // String function __construct($userToken) { // from ./common/keys.php global $userToken, $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID; $requestXml = $this->setupRequestXml($userToken); // defined below $verb = 'GetStore'; //Create a new eBay session with all details pulled in from included keys.php $session = new eBaySession($userToken, $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID, $verb); $this->responseXml = $session->sendHttpRequest($requestXml); if(stristr($this->responseXml, 'HTTP 404') || $this->responseXml == '') die('<P>Error sending request'); //Xml string is parsed and creates a SimpleXML object $this->resp = simplexml_load_string($this->responseXml); return; } // This method (function) is mostly for debugging public function printResp(){ print "<pre>"; //print_r($this->responseXml); print_r($this->resp->Store->CustomCategories); print "</pre>"; } public function getStoreCategoriesAsHTML_PickList() { $retn = '<select name="storeCategory">'; foreach($this->resp->Store->CustomCategories->CustomCategory as $cat) { $retn .= "<option value=\"$cat->CategoryID\">$cat->Name</option>"; } // foreach $retn .= '</select>'; return $retn; } protected function setupRequestXml($userToken) { global $compatabilityLevel; $requestXml = '<?xml version="1.0" encoding="utf-8"?>'; $requestXml .= '<GetStoreRequest xmlns="urn:ebay:apis:eBLBaseComponents">'; $requestXml .= "<Version>$compatabilityLevel</Version>"; $requestXml .= '<CategoryStructureOnly>true</CategoryStructureOnly>'; $requestXml .= '<RequesterCredentials>'; $requestXml .= "<eBayAuthToken>$userToken</eBayAuthToken>"; $requestXml .= '</RequesterCredentials>'; $requestXml .= '</GetStoreRequest>'; return $requestXml; } // This method (function) is mostly for debugging public function printResp2(){ foreach($this->resp->Store->CustomCategories->CustomCategory as $cat) { /*********************** niveau 1 ****************************/ echo utf8_decode($cat->Name); if ($cat->ChildCategory->Name <> '') { /*********************** niveau 2 ****************************/ foreach($cat->ChildCategory as $cat2) { echo "</br>"; echo "-----" . utf8_decode($cat2->Name); if ($cat2->ChildCategory->Name <> '') { /*********************** niveau 3 ****************************/ foreach($cat2->ChildCategory as $cat3) { echo "</br>"; echo "----------" . utf8_decode($cat3->Name); if ($cat3->ChildCategory->Name <> '') { /*********************** niveau 4 ****************************/ foreach($cat3->ChildCategory as $cat4) { echo "</br>"; echo "----------" . utf8_decode($cat4->Name); if ($cat3->ChildCategory->Name <> '') { /*********************** niveau 5 ****************************/ echo "</br>"; foreach($cat4->ChildCategory as $cat5) { echo "----------" . utf8_decode($cat5->Name); } }else{ echo "-----<b> " . $cat4->CategoryID."</b>"; } } }else{ echo "-----<b> " . $cat3->CategoryID."</b>"; } } }else{ echo "-----<b> " . $cat2->CategoryID."</b>"; } } } else { echo "-----<b> " . $cat->CategoryID ."</b>"; } echo "</br>"; } // foreach } } // class // Sample run // Uncomment these lines and "run" the class to see HTML output $storeCats = new StoreCategories($userToken); // $userToken from ./keys.php // $storeCats->printResp(); echo "<hr>"; $storeCats->printResp2(); // print $storeCats->getStoreCategoriesAsHTML_PickList(); ?> Link to comment Share on other sites More sharing options...
Recommended Posts