/** * Set the attribute value (and infer the type automatically). * * @param $value */ public function setValue($values) { if (!is_array($values)) { $values = [$values]; } if (count($values) === 0 || is_null(reset($values))) { return; } $this->type = Xml::attributeType(reset($values)); $this->value = []; foreach ($values as $value) { if ('DATE' === $this->type && !Date::isEmpty($value)) { $value = Date::format($value); } $this->value[] = $value; } }
/** * Set the attribute value (and infer the type automatically). * * @param $value */ public function setValue($value) { $type = Xml::attributeType($value); if ('DATE' === $type && !Date::isEmpty($value)) { $value = Date::format($value); } $this->value = $value; $this->type = $type; }
/** * Add a preferred distributor. * * @param $rank * @param $legacyDistributorId * @param null $from * @param null $till */ public function addPreferredDistributor($rank, $legacyDistributorId, $from = null, $till = null) { $this->preferredDistributors[] = ['legacyDistributorId' => $legacyDistributorId, 'effectiveFrom' => !Date::isEmpty($from) ? Date::format($from) : null, 'effectiveTill' => !Date::isEmpty($till) ? Date::format($till) : null, 'rank' => !is_null($rank) ? (int) $rank : null]; }
/** * Three pricing values can be specified, along with an effective date (pass null if unknown, to use current time) * The previous price is optional, and its presence determines the exported `isStrikethrough` boolean value * @param int $retail * @param int $current * @param int $previous * @param $effectiveDate */ public function setPricing($retail = 0, $current = 0, $previous = 0, $effectiveDate = null) { $effectiveDate = Date::format($effectiveDate); $retailPrice = $this->renderPrice('BaseRetail', $retail, 'BASE'); $currentPrice = $this->renderPrice('CurrentPrice', $current, 'BASE'); $previousPrice = $previous > 0 ? $this->renderPrice('ComparisonPrice', $previous, 'LIST_PRICE') : ''; $strikeThrough = Xml::escape($previous > 0); $this->pricing = <<<XML <martId>5</martId> <sku>{$this->sku}</sku> {$retailPrice} <StoreFrontPrice><PriceInfo> {$currentPrice} {$previousPrice} <PriceDisplayCodes><isStrikethrough>{$strikeThrough}</isStrikethrough></PriceDisplayCodes> <effectiveDate>{$effectiveDate}</effectiveDate> </PriceInfo></StoreFrontPrice> XML; }
/** * Creates a new feed document, for the specified timestamp (defaults to now if empty) * * @param $timestamp */ public function __construct($timestamp = null) { $this->timestamp = Date::format($timestamp); }
/** * @todo: should SPEC_DEFAULT_END_DATE be used if $end empty? * * @param $start * @param $end */ public function setDates($start, $end) { $this->values['online_from'] = Date::format($start); $this->values['online_to'] = Date::format($end); }