PHP library for working with Demandware XML files

Overview

PHP Demandware XML

A PHP library for working with Demandware XML files.

Exporting: Supports category, product, variant and assignment files and allows elements to be added in the order that makes sense for your code - they'll be exported in the sequence specified by the XSD automatically, and custom attribute elements are ordered by attribute ids for consistency between exports.

Validation: Automatically validates files up to 1Gb (against the included XSD schemas) after exporting.

Parsing: Retrieve category, assignment, product, variation, set and bundle information from an XML file, either as an array, or yield using generators. Maps IDs to the more useful elements and, optionally, attributes.

Installation

Run composer require fusionspim/php-demandware-xml.

Usage

See tests for examples on how to use, along with the files within tests/fixtures for output examples.

Future plans

  • Export all root elements sorted by their first attribute value (similar to custom attributes) to ease manual comparison/diffs.
  • Convert nested elements currently implemented with string concatenation/loops to nodes (they work, but would be nice for consistency/robustness) & deal with the setClassification()/catalog-id hack ;)
  • Canonicalise two sets of XML files and report on different IDs, elements and attributes (useful when different systems/processes have exported the files)
Comments
  • Helper classes to export Demandware XML files

    Helper classes to export Demandware XML files

    This library is intended to encapsulate all logic and schemas required to export/validate Demandware XML files. There are tests that cover all the different options/functions available. Looking for feedback, and once everyone is happy, make the repo public...

    opened by weshooper 8
  • Fix for assignments test data

    Fix for assignments test data

    Noticed that PROD1 was supposed to have two assignments, but the test array was structured such that CAT1 assignment would be lost.

    Have fixed this, but getting an error with testAssignmentsParser() now and can’t spot the issue - halp!

    opened by weshooper 6
  • Add return value to validate()

    Add return value to validate()

    Fixes

    PHP Fatal error: Uncaught TypeError: Return value of DemandwareXml\Xml::validate() must be of the type boolean, none returned in /vendor/fusionspim/php-demandware-xml/src/Xml.php:56

    opened by maxakropolis 5
  • Added a parser

    Added a parser

    Added a parser to provide a simple interface for retrieving assignments/categories/products from Demandware XML files.

    Currently only returns select elements/details (to expand later as/when needed), along with all custom attributes.

    Have also skipped validation of XML files against XSD schemas for files over 500MB, since at that size, DomDocument silently exits the script. Needs looking at another time, but don’t typically see files that large.

    opened by weshooper 5
  • Fix setSitemap Typehints

    Fix setSitemap Typehints

    To simplify https://github.com/fusionspim/fusions/pull/8172

    The is_null checks within this method suggest that it was designed with the possibility of parameters being null.

    opened by liamkeily 3
  • Added new low memory parser (v2)

    Added new low memory parser (v2)

    Based on feedback on the low memory parser v1, I've done some refactoring so our parser class can now yield its results, or return them in an array. The parser is now a simple class that you plug node parsers into, which makes it more flexible.

    Here's a summary of what's changed:

    • Calling parse() uses yield to return each element, which results in reduced memory usage.
    • Validates XML using XMLReader so document does not have to be loaded into memory.
    • All node parsing has been abstracted to separate classes.
    • We can now write and plugin our own custom node parsers for specific scenarios.
    • Validation is done directly via a method, rather than in the constructor like Parser, for flexibility.

    Some quick examples:

    Yielding assignments:

    $parser = new Parser(__DIR__ . '/fixtures/assignments.xml');
    $parser->validate();
    
    foreach ($parser->parse(AssignmentNodeParser::class) as $productId => $assignment) {
        //...
    }
    

    Parsing into an array:

    $parser = new Parser(__DIR__ . '/fixtures/products.xml');
    $parser->validate();
    
    $results = $parser->toArray([
        'assignments' => AssignmentNodeParser::class,
        'categories' => CategorySimpleNodeParser::class,
    ], ['assignments']);
    
    print_r($results['assignments']);
    print_r($results['categories']);
    
    opened by ziadoz 3
  • Sanitise Invalid XML Characters

    Sanitise Invalid XML Characters

    • Added new sanitise() method that removes invalid XML characters (e.g. record separator).
    • Invalid characters are replaced with a single space.
    • Updated escape() to sanitise automatically.
    • Ensured raw long-description value gets sanitised.
    • Updated unit tests to include invalid character.

    PHP Warning: DOMNode::appendChild(): Document Fragment is empty in php-demandware-xml/src/Document.php on line 95

    opened by ziadoz 3
  • Refactored tests to use PHPUnit

    Refactored tests to use PHPUnit

    I've refactored the tests verbatim into some basic PHPUnit tests. I just had to add a new method to Document that allows access to the internal DOMElement so I could compare the XML structures.

    screen shot 2015-07-15 at 19 39 27

    Update Composer and then run php vendor/bin/phpunit to run the tests.

    opened by ziadoz 3
  • Bump laravel/pint from 1.2.1 to 1.3.0

    Bump laravel/pint from 1.2.1 to 1.3.0

    Bumps laravel/pint from 1.2.1 to 1.3.0.

    Release notes

    Sourced from laravel/pint's releases.

    v1.3.0

    Changed

    Changelog

    Sourced from laravel/pint's changelog.

    v1.3.0 - 2022-12-20

    Changed

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    Dependencies 
    opened by dependabot[bot] 2
  • Bump fusionspim/php-cs-fixer-config from 6.0.1 to 7.0.0

    Bump fusionspim/php-cs-fixer-config from 6.0.1 to 7.0.0

    Bumps fusionspim/php-cs-fixer-config from 6.0.1 to 7.0.0.

    Release notes

    Sourced from fusionspim/php-cs-fixer-config's releases.

    Enable new fixers (and internal refactoring)

    This is a major new version and there are too many new fixers to list.

    Comparing DEFAULT_RULES isn't possible, since a lot of rules have also been removed due to adopting presets.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    Dependencies 
    opened by dependabot[bot] 2
  • Bump ergebnis/composer-normalize from 2.8.2 to 2.9.0

    Bump ergebnis/composer-normalize from 2.8.2 to 2.9.0

    Bumps ergebnis/composer-normalize from 2.8.2 to 2.9.0.

    Release notes

    Sourced from ergebnis/composer-normalize's releases.

    2.9.0

    • github-actions(deps): bump actions/checkout from v2.3.2 to v2.3.3 (#555), by @dependabot[bot]
    • composer(deps-dev): bump phpstan/phpstan from 0.12.43 to 0.12.44 (#556), by @dependabot[bot]
    • composer(deps-dev): bump phpstan/phpstan from 0.12.44 to 0.12.45 (#557), by @dependabot[bot]
    • composer(deps-dev): bump symfony/filesystem from 5.1.5 to 5.1.6 (#558), by @dependabot[bot]
    • composer(deps-dev): bump phpstan/phpstan from 0.12.45 to 0.12.46 (#559), by @dependabot[bot]
    • composer(deps-dev): bump psalm/plugin-phpunit from 0.12.1 to 0.12.2 in /tools (#560), by @dependabot[bot]
    • composer(deps-dev): bump phpstan/phpstan from 0.12.46 to 0.12.47 (#561), by @dependabot[bot]
    • composer(deps-dev): bump phpstan/phpstan from 0.12.47 to 0.12.48 (#562), by @dependabot[bot]
    • composer(deps-dev): bump symfony/filesystem from 5.1.6 to 5.1.7 (#564), by @dependabot[bot]
    • composer(deps-dev): bump ergebnis/test-util from 1.1.0 to 1.2.0 (#563), by @dependabot[bot]
    • composer(deps-dev): bump ergebnis/test-util from 1.2.0 to 1.3.0 (#565), by @dependabot[bot]
    • github-actions(deps): bump shivammathur/setup-php from 2.5.0 to 2.6.0 (#566), by @dependabot[bot]
    • github-actions(deps): bump actions/stale from v3.0.11 to v3.0.12 (#567), by @dependabot[bot]
    • github-actions(deps): bump actions/cache from v2.1.1 to v2.1.2 (#568), by @dependabot[bot]
    • composer(deps-dev): bump vimeo/psalm from 3.16 to 3.17.1 in /tools (#569), by @dependabot[bot]
    • composer(deps-dev): bump phpstan/phpstan from 0.12.48 to 0.12.49 (#570), by @dependabot[bot]
    • composer(deps-dev): bump vimeo/psalm from 3.17.1 to 3.17.2 in /tools (#571), by @dependabot[bot]
    • composer(deps-dev): bump phpstan/phpstan from 0.12.49 to 0.12.50 (#573), by @dependabot[bot]
    • composer(deps-dev): bump vimeo/psalm from 3.17.2 to 3.18.0 in /tools (#574), by @dependabot[bot]
    • github-actions(deps): bump shivammathur/setup-php from 2.6.0 to 2.7.0 (#575), by @dependabot[bot]
    • composer(deps-dev): bump vimeo/psalm from 3.18.0 to 3.18.2 in /tools (#576), by @dependabot[bot]
    • Enhancement: Update schema.json (#572), by @ergebnis-bot
    • Fix: Use assertStringContainsString() (#577), by @localheinz
    • Fix: Require PHP 7.2 for tools (#578), by @localheinz
    • Fix: Merge tools/composer.json into composer.json (#579), by @localheinz
    • Fix: Remove configuration (#580), by @localheinz
    • Enhancement: Synchronize with ergebnis/php-library-template (#581), by @localheinz
    • Fix: Require and use composer/composer:^1.10.15 (#582), by @localheinz
    Changelog

    Sourced from ergebnis/composer-normalize's changelog.

    [2.9.0][2.9.0]

    For a full diff see [2.8.2...2.9.0][2.8.2...2.9.0].

    Changed

    Fixed

    • Required at least composer/composer:^1.10.15 and use composer/composer:1.10.15 for composer-normalize.phar (#582), by [@localheinz]
    Commits
    • 4b77c0e Merge pull request #582 from ergebnis/fix/composer
    • 7af6491 Fix: Require and use composer/composer:^1.10.15
    • 8c650dd Merge pull request #581 from ergebnis/feature/synchronize
    • 0eb579c Enhancement: Synchronize with ergebnis/php-library-template
    • c134131 Merge pull request #580 from ergebnis/fix/dependabot
    • b275fc1 Fix: Remove configuration
    • 869068b Merge pull request #579 from ergebnis/fix/dependencies
    • 5b2f341 Fix: Merge tools/composer.json into composer.json
    • d41dfa2 Merge pull request #578 from ergebnis/fix/version
    • 2a56c49 Merge pull request #577 from ergebnis/fix/assertion
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    Dependencies 
    opened by dependabot[bot] 2
  • Reorder `setPageAttributes()` parameters

    Reorder `setPageAttributes()` parameters

    From:

    public function setPageAttributes(?string $pageTitle = null, ?string $pageDescription = null, ?string $pageKeywords = null, ?string $pageUrl = null): void

    To:

    public function setPageAttributes(?string $pageUrl = null, ?string $pageTitle = null, ?string $pageDescription = null, ?string $pageKeywords = null): void

    This would be a breaking change, however pages tend to always have a URL, but may not need keywords. Therefore it'd mean not needing to pass null for keywords.

    opened by weshooper 0
Releases(6.0.1)
Owner
Fusions PIM
Smart product information management
Fusions PIM
A simple library for management the DOM (XML, HTML) document.

A simple library for management the DOM (XML, HTML) document.

Alexey 3 Oct 1, 2022
A library for working with StatsD in PHP

StatsD PHP Library A library for working with StatsD in PHP. Install Via Composer: composer require league/statsd To use the Statsd Service Provider,

The League of Extraordinary Packages 339 Dec 19, 2022
PHP library with basic objects and more for working with Facebook/Metas Conversions API

PHP library with basic objects and more for working with Facebook/Metas Conversions API Installation The easiest way to install this library is by ins

null 5 Dec 5, 2022
Learning about - Basic HTML & CSS, JSON, XML, Session & Cookies, CRUD Operations in Php using MySQL and Create MVC from scratch

This Project is based on course CSC 3215. Learning about - Basic HTML & CSS, JSON, XML, Session & Cookies, CRUD Operations in Php using MySQL and Create MVC (Model–View–Controller) from scratch. Just learning about web technologies, Not focusing on UI (Bootstrap or other 3rd-Party UI libraries or frameworks).

Alvi Hasan 5 Sep 21, 2022
The main website source code based on php , html/css/js and an independent db system using xml/json.

jsm33t.com Well umm, a neat website LIVE SITE » View Demo · Report Bug · Request a feature About The Project Desc.. Built Using Php UI Frameworks Boot

Jasmeet Singh 5 Nov 23, 2022
An utility component for XML usage and best practices in PHP

An utility component for XML usage and best practices in PHP

Laminas Project 13 Nov 26, 2022
World countries - available in multiple languages, in CSV, JSON, PHP, SQL and XML formats

Constantly updated lists of world countries and their associated alpha-2, alpha-3 and numeric country codes as defined by the ISO 3166 standard, available in CSV, JSON , PHP, SQL and XML formats, in multiple languages and with national flags included; also available are the ISO 3166-2 codes of provinces/ states associated with the countries

Stefan Gabos 1k Dec 29, 2022
[READ-ONLY] CakePHP Utility classes such as Inflector, Text, Hash, Security and Xml. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP Utility Classes This library provides a range of utility classes that are used throughout the CakePHP framework What's in the toolbox? Hash A

CakePHP 112 Feb 15, 2022
The easiest way to match data structures like JSON/PlainText/XML against readable patterns. Sandbox:

PHP Matcher Library created for testing all kinds of JSON/XML/TXT/Scalar values against patterns. API: PHPMatcher::match($value = '{"foo": "bar"}', $p

Coduo 774 Dec 31, 2022
Simple XML-RPC API

Readme Ripcord: Easy XML-RPC Client and Server for PHP 5 ========================================================================

Saravanakumar Arumugam 1 Nov 22, 2021
Rah sitemap - XML sitemap generator for Textpattern CMS

rah_sitemap Packagist | Issues | Donate Sitemap plugin for Textpattern CMS. Generates Sitemaps.org XML sitemaps for your site, which help Google and o

Jukka Svahn 7 May 13, 2022
A great Start for your next Magento Theme's local.xml file

Magento-local.xml-Template A Great Start for your next Magento Theme's local.xml file - <?xml version="1.0"?> <layout> <!-- Add/Remove Items From H

Bryan Littlefield 36 Apr 19, 2021
Improve default Magento 2 Import / Export features - cron jobs, CSV , XML , JSON , Excel

Improve default Magento 2 Import / Export features - cron jobs, CSV , XML , JSON , Excel , mapping of any format, Google Sheet, data and price modification, improved speed and a lot more!

Firebear Studio 173 Dec 17, 2022
Sistema disema con aplicación de consultas en XML y JSON

disema-XML-JSON Sistema web para empresa de diseño "Disema", con operaciones básicas CRUD y uso de html, JQ, JS, php y css. Incluye aplicación de cons

null 1 Jan 12, 2022
laminas-xml2json provides functionality for converting XML structures to JSON

laminas-xml2json This package is considered feature-complete, and is now in security-only maintenance mode, following a decision by the Technical Stee

Laminas Project 13 Dec 28, 2022
PluXml, Moteur de Blog et CMS à l'XML sans base de données

PluXml Créez un site web performant en toute simplicité et sans base de données. Télécharger PluXml 5.8.7 (zip) Version bugfix (5.8.8) en développemen

PluXml 192 Dec 14, 2022
A small CLI tool to check missing dependency declarations in the composer.json and module.xml

Integrity checker Package allows to run static analysis on Magento 2 Module Packages to provide an integrity check of package. Supported tools: Compos

run_as_root GmbH 13 Dec 19, 2022
Iran decoration platform is an open source Php web application where you can find your job as a freelancer working in people home in decoration positions and others.

Iran-Decoration Platform Iran decoration platform is an open source Php web application where you can find your job as a freelancer working in people

AmirHossein Mohammadi 8 Dec 14, 2022
A set of utilities for working with vk api!

vk-utils Документация на русском языке Installation composer require labile/vk-utils How to use it? Simple example use Astaroth\VkUtils\Client; $api

null 1 Jan 3, 2022