You are here

function _uc_importer_export_attributes in Ubercart 5

Export product attributes as XML.

1 call to _uc_importer_export_attributes()
uc_importer_export in uc_importer/uc_importer.module
Constructs the XML representation of the store from the ids given.

File

uc_importer/uc_importer.module, line 509
XML product importer and exporter.

Code

function _uc_importer_export_attributes($attributes) {
  $xml = '<attributes>';
  foreach ($attributes as $aid) {
    $attribute = uc_attribute_load($aid);
    $xml .= '<attribute>';
    $xml .= '<id>' . $attribute->aid . '</id>';
    $xml .= '<name>' . htmlspecialchars($attribute->name, ENT_QUOTES, "UTF-8") . '</name>';
    $xml .= '<ordering>' . $attribute->ordering . '</ordering>';
    if (is_array($attribute->options) && count($attribute->options)) {
      $xml .= '<options>';
      foreach ($attribute->options as $option) {
        $xml .= '<option>';
        $xml .= '<id>' . $option->oid . '</id>';
        $xml .= '<name>' . htmlspecialchars($option->name, ENT_QUOTES, "UTF-8") . '</name>';
        $xml .= '<price>' . $option->price . '</price>';
        $xml .= '<weight>' . $option->weight . '</weight>';
        $xml .= '<ordering>' . $option->ordering . '</ordering>';
        $xml .= uc_importer_invoke('export', 'option', $option->oid);
        $xml .= '</option>';
      }
      $xml .= '</options>';
    }
    $xml .= uc_importer_invoke('export', 'attribute', $aid);
    $xml .= '</attribute>';
  }
  $xml .= '</attributes>';
  return $xml;
}