コード例 #1
0
 public function getDevices($id, $count, $offset, $orderBy, $order)
 {
     if (!isset($orderBy) or empty($orderBy)) {
         $orderBy = "name";
     }
     if (!isset($order) or empty($order)) {
         $order = "ASC";
     }
     if (!isset($count) or empty($count)) {
         $count = "10";
     }
     $product = new Object\Product\Listing();
     $product->setOffset($offset);
     $product->setLimit($count);
     $product->setOrderKey($orderBy);
     $product->setOrder($order);
     if (isset($id) and $id != "") {
         $product->setCondition("o_id='" . $id . "'");
     }
     $i = 0;
     foreach ($product as $key => $value) {
         $imagesArray = array();
         $return = array();
         $imagePropertis = array();
         for ($j = 0; $j < count($value->images->items); $j++) {
             $imagePropertis[$j] = array('imageId' => $value->images->items[$j]->Image->id, 'imageName' => $value->images->items[$j]->ImageName, 'filename' => $value->images->items[$j]->Image->filename, 'path' => $value->images->items[$j]->Image->path);
         }
         if ($value->is_small_product == 1) {
             $small_product = array("type" => $value->specificationLarge->items[0]->type, "quota" => $value->specificationLarge->items[0]->quota, "numberOfUsers" => $value->specificationLarge->items[0]->numberOfUsers, "typeUsage" => $value->specificationLarge->items[0]->typeUsage, "typePreferredNetwork" => $value->specificationLarge->items[0]->typePreferredNetwork, "fieldname" => $value->specificationLarge->items[0]->fieldname);
         } else {
             $small_product = array();
         }
         if ($value->is_large_product == 1) {
             $large_product = array("type" => $value->specificationLarge->items[0]->type, "quota" => $value->specificationLarge->items[0]->quota, "numberOfUsers" => $value->specificationLarge->items[0]->numberOfUsers, "typeUsage" => $value->specificationLarge->items[0]->typeUsage, "typePreferredNetwork" => $value->specificationLarge->items[0]->typePreferredNetwork, "fieldname" => $value->specificationLarge->items[0]->fieldname);
         } else {
             $large_product = array();
         }
         $products[$i] = array('o_id' => $value->o_id, 'o_key' => $value->o_key, 'name' => $value->name, 'slugName' => $value->slugName, 'price' => $value->price, 'images' => $imagePropertis, 'deviceModel' => $value->deviceModel, 'is_large_product' => $value->is_large_product, 'is_small_product' => $value->is_small_product, 'description' => $value->description, 'rrp' => $value->rrp, 'specification' => array("large_product" => $large_product, "small_product" => $small_product));
         $i++;
     }
     if ($i > 0) {
         $status = "success";
         $message = "success";
     } else {
         $status = "failed";
         $message = "data not found";
     }
     $arrayReturn = array("status" => $status, "message" => $message, "data" => $products);
     return $arrayReturn;
 }