/** * Return new Offer with all values set that are needed to update one * @param string $id * @param float $price * @param string $deliveryCode * @param bool $publish * @param string|null $referenceCode * @param string|null $description * @return Offer */ public static function toUpdate($id, $price, $deliveryCode, $publish, $referenceCode, $description) { $offer = new self(); $offer->setId($id); $offer->setPrice($price); $offer->setDeliveryCode($deliveryCode); $offer->setPublish($publish); $offer->setReferenceCode($referenceCode); $offer->setDescription($description); return $offer; }
/** * @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; }
/** * @see CultureFeed_Cdb_IElement::parseFromCdbXml(SimpleXMLElement $xmlElement) * @return CultureFeed_Cdb_List_Item */ public static function parseFromCdbXml(SimpleXMLElement $xmlElement) { $attributes = $xmlElement->attributes(); $item = new self(); // Set ID. $item->setCdbId((string) $attributes['cidn']); if (!empty($attributes['private'])) { $item->setPrivate((bool) $attributes['private']); } if (!empty($attributes['externalid'])) { $item->setExternalId((string) $attributes['externalid']); } $item->setTitle((string) $attributes['title']); if (!empty($attributes['shortdescription'])) { $item->setShortDescription((string) $attributes['shortdescription']); } if (!empty($attributes['thumbnail'])) { $item->setThumbnail((string) $attributes['thumbnail']); } if (!empty($attributes['address'])) { $item->setAddress((string) $attributes['address']); } if (!empty($attributes['city'])) { $item->setCity((string) $attributes['city']); } if (!empty($attributes['zip'])) { $item->setZip((string) $attributes['zip']); } if (!empty($attributes['latlng'])) { $item->setCoordinates((string) $attributes['latlng']); } if (!empty($attributes['location'])) { $item->setLocation((string) $attributes['location']); } if (!empty($attributes['locationid'])) { $item->setLocationId((string) $attributes['locationid']); } if (!empty($attributes['calendarsummary'])) { $item->setCalendarSummary((string) $attributes['calendarsummary']); } if (!empty($attributes['itemtype'])) { $item->setType((string) $attributes['itemtype']); } if (!empty($attributes['price'])) { $item->setPrice((string) $attributes['price']); } if (!empty($attributes['pricedescription'])) { $item->setPriceDescription((string) $attributes['pricedescription']); } if (!empty($attributes['agefrom'])) { $item->setAgeFrom((string) $attributes['agefrom']); } if (!empty($attributes['performers'])) { $item->setPerformers((string) $attributes['performers']); } return $item; }
/** * @param \SimpleXMLElement $product * @return ErpProductEntity */ public static function createFromCatalogXmlResponse(\SimpleXMLElement $product) { $self = new self(); $sku = isset($product->attributes()->ItemNo) ? (string) $product->attributes()->ItemNo : null; if (!$sku) { throw new \InvalidArgumentException('Invalid product downloaded from catalog'); } $self->setSku($sku); $self->setTitle((string) $product->Description); $self->setLastUpdated(new \DateTime((string) $product->attributes()->LastUpdated)); $self->setDescription((string) $product->Description); foreach ($product->SupplementalData as $data) { foreach ($data->attributes() as $k => $v) { switch ((string) $v) { case 'webcategory': $self->setCategory((string) $data); break; } } } $self->setPrice((string) $product->Pricing->UnitPrice); $self->setQty((int) (string) $product->Availability->QtyAvailable); return $self; }