public function load()
 {
     $order = new Order();
     $json = file_get_contents($this->filename);
     $data = json_decode($json, true);
     $order->setRef($data['ref']);
     $order->setState($data['state']);
     foreach ($data['attributes'] as $attributedata) {
         $attribute = new Attribute();
         $attribute->setKey($attributedata['key']);
         $attribute->setValue($attributedata['value']);
         $order->addAttribute($attribute);
     }
     foreach ($data['lines'] as $linedata) {
         $orderline = new OrderLine();
         $orderline->setQuantity($linedata['quantity']);
         $orderline->setUnitPrice($linedata['unitprice']);
         $orderline->setTitle($linedata['title']);
         $vat = new Vat();
         $vat->setValue($linedata['vatvalue']);
         $orderline->setVat($vat);
         foreach ($linedata['attributes'] as $attributedata) {
             $attribute = new Attribute();
             $attribute->setKey($attributedata['key']);
             $attribute->setValue($attributedata['value']);
             $orderline->addAttribute($attribute);
         }
         $order->addLine($orderline);
     }
     return $order;
 }
 public function load()
 {
     $product = new Product();
     $json = file_get_contents($this->filename);
     $data = json_decode($json, true);
     $product->setCode($data['code']);
     $product->setName($data['name']);
     $product->setState($data['state']);
     foreach ($data['attributes'] as $attributedata) {
         $attribute = new Attribute();
         $attribute->setKey($attributedata['key']);
         $attribute->setValue($attributedata['value']);
         $product->addAttribute($attribute);
     }
     return $product;
 }