예제 #1
0
 static function currentBasket($asObject = true, $byOrderID = -1)
 {
     $basketList = array();
     if ($byOrderID != -1) {
         $basketList = eZPersistentObject::fetchObjectList(eZBasket::definition(), null, array("order_id" => $byOrderID), null, null, $asObject);
     } else {
         $http = eZHTTPTool::instance();
         $sessionID = $http->sessionID();
         $basketList = eZPersistentObject::fetchObjectList(eZBasket::definition(), null, array("session_id" => $sessionID), null, null, $asObject);
     }
     $currentBasket = false;
     if (count($basketList) == 0) {
         $db = eZDB::instance();
         $db->begin();
         $collection = eZProductCollection::create();
         $collection->store();
         $currentBasket = new eZBasket(array("session_id" => $sessionID, "productcollection_id" => $collection->attribute("id")));
         $currentBasket->store();
         $db->commit();
     } else {
         $currentBasket = $basketList[0];
     }
     return $currentBasket;
 }