Contact Contact Show All Awards & Recognition
Contact
Show All Awards & Recognition

XML Tool

not-reviewed

Export/Import

Version

v1.2.0

Last updated

Compatible Pimcore Version

>=5.0

Contact

https://basilicom.de/de/pimcore

Issues

https://github.com/basilicom/xml-tool-bundle/issues

No  Reviewer

XML Tool

Export/Import

Project Summary

Adds commands and REST API for dealing with XML data. For now, parts of the Object tree can be exported recursively, retaining the hierarchy. Exports can be triggered by a console command and written to stdout, a file or an pimcore asset. If enabled, exports can be made available via a REST API, too. Only a minimum configuration is needed, Pimcore data is exported as-is, optionally modified by a XSLT.


Readme

Basilicom Xml Tool bundle for Pimcore

Adds commands for dealing with XML data. For now, parts of the Object tree can be exported recursively, retaining the hierarchy.

Exports can be triggered by a console command and written to stdout, a file or an pimcore asset.

If enabled, exports can be made available via a REST API, too.

Table of contents

License

GPLv3 - see: LICENSE

Requirements

  • PHP >= 7.1
  • Pimcore >= 5.0.0
  • XSL PHP extension for --xslt option support

Installation

1) Install the bundle using composer composer require basilicom/xml-tool-bundle dev-master. 2) Execute bin/console pimcore:bundle:enable BasilicomXmlToolBundle

Configuration

n/a

Console Usage

Use the export command to export command to export the Object tree, example for path /foo:

    bin/console basilicom:xmltool:export /foo

Example output:

Note: The Object tree /foo contains in the example a single Object of the Object Class Bar with a single Input property of name.

Exporting tree of Objects starting at /foo
<?xml version="1.0"?>
<root id="1" type="folder" key="" class="Folder">
  <:children>
    <Bar id="4" type="object" key="baaaar" class="Bar">
      <name><![CDATA[bar]]></name>
    </Bar>
  </:children>
</root>

Complex example:

  • do not export the attributes / fields of objects attached via relations
  • export variants of objects, too
  • change the name of the root node to 'Products'
  • apply a sample xslt
  • export to a pimcore asset /output/my-export.xml
./bin/console basilicom:xmltool:export --omit-relation-object-fields --include-variants --root=products --asset=/output/my-export.xml --xslt sample.xsl /exp

Sample XSLT:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="/">
    <objects>
    <xsl:for-each select="//Leaf">
      <object>
        <name><xsl:value-of select="name"/></name>
      </object>
    </xsl:for-each>
    </objects>
  </xsl:template>
</xsl:stylesheet>

For all options (writing to a file, etc.), see:

    bin/console basilicom:xmltool:export --help

Usage: REST API

In order to enable the REST API, place a configuration file in app/config/local/xmltool.yml:

basilicom_xml_tool:
  api:
    enabled: true
    endpoints:
      test1:
        token: secrettoken0815
        root: Products # Root name of the exported XML file
        path: /export/products # Path to the exporting objects
        xslt: ../sample.xsl
        include_variants: true
        omit_relation_object_fields: true
      test2:
        path: /sample/obj/path

This example enables two endpoint URLs:

Limitations

Only a few field types are supported for now:

  • input
  • select
  • wysiwyg
  • textarea
  • date
  • datetime
  • ManyToManyObjectRelation
  • color
  • rgbaColor
  • localizedFields

To extend the supported types, implement a getForType* method in Service/Xml.php.

Review status

not-reviewed

?>

Version

v1.2.0

Last updated

Compatible Pimcore Version

>=5.0

Contact

https://basilicom.de/de/pimcore

Issues

https://github.com/basilicom/xml-tool-bundle/issues

No  Reviewer