Example #1
0
 /**
  * @param SimpleXMLElement $xml
  *
  * @return Option
  */
 public static function createFromXML(SimpleXMLElement $xml)
 {
     /*
     <option visiblity="NOT_VISIBLE_BY_CONSUMER_OPTIONAL" price="0" name="Cash on delivery"/>
     */
     $attributes = $xml->attributes();
     $children = $xml->children();
     $option = new self();
     $option->setVisibility($attributes['visiblity']);
     $option->setPrice($attributes['price']);
     $option->setName($attributes['name']);
     if (isset($children->chracteristic)) {
         foreach ($children->chracteristic as $characteristicXml) {
             $option->addCharacteristic(Characteristic::createFromXML($characteristicXml));
         }
     }
     return $option;
 }