Ejemplo n.º 1
0
 /**
  * Populates <variation-attribute-values> child elements, from a mapping of attribute values to names
  *
  * @param array $map
  */
 public function addTags($map = [])
 {
     $xml = '';
     foreach ($map as $id => $value) {
         $xml .= '<variation-attribute-value value="' . Xml::escape($id) . '">
                     <display-value xml:lang="x-default">' . Xml::escape($value) . '</display-value>
                 </variation-attribute-value>';
     }
     $this->elements['variation-attribute-values'] = $xml;
 }
Ejemplo n.º 2
0
 /**
  * Populates <custom-attributes> child elements, from a mapping of attribute ids to values
  * Values can be empty and still exported, however attributes with null values aren't exported
  * Attributes are exported sorted alphabetically by id for consistency and ease of diffing exports...
  *
  * @param array $map
  */
 public function setCustomAttributes(array $map)
 {
     ksort($map);
     $xml = '';
     foreach ($map as $key => $value) {
         if (is_null($value)) {
             continue;
         }
         $xml .= '<custom-attribute attribute-id="' . Xml::escape($key) . '">';
         if (is_array($value)) {
             foreach ($value as $individual) {
                 if (is_null($individual)) {
                     continue;
                 }
                 $xml .= '<value>' . Xml::escape($individual) . '</value>' . PHP_EOL;
             }
         } else {
             $xml .= Xml::escape($value);
         }
         $xml .= '</custom-attribute>' . PHP_EOL;
     }
     $this->elements['custom-attributes'] = $xml;
 }
Ejemplo n.º 3
0
 /**
  * Only applies to Sets
  *
  * @param array $products
  */
 public function setProducts(array $products = [])
 {
     $xml = '';
     foreach ($products as $id) {
         $xml .= '<product-set-product product-id="' . Xml::escape($id) . '" />' . PHP_EOL;
     }
     $this->elements['product-set-products'] = $xml;
 }