Vinai / groupscatalog2

Magento extension to enable you to hide categories and products from customers depending on their customer group. This is a Magento 1.6 and newer compatible version of the Netzarbeiter Customer Groups Catalog extension.
139 stars 60 forks source link

XML Parsing error when exporting data out to .xml file #97

Closed MichaelEOConnor closed 10 years ago

MichaelEOConnor commented 10 years ago

Hello, We are using another extension to export all product information out to a .xml file. When the information is exported, it generates the following data as part of the XML file ( _ added to avoid webpage parsing the text):::

<groupscatalog2_groups>
<0><![CDATA[-2]]></0>
</groupscatalog2_groups>

I believe this relates to the "Hide From Groups" selection in the product area of the front-end. The problem is the blank/zero (<0>) field/attribute name is causing an error and not allowing the XML file to be parsed correctly. Is there a way (database wise or other) that I can locate and re-name this attribute so that the XML can be generated with a field name? Thanks.

Vinai commented 10 years ago

Hi,

the problem is that the attribute property contains a numerically indexed array. The extension exporting the data doesn't handle that case, it simply assumes that all arrays use strings that are valid XML node names as their keys. The proper way to export that array would be to simply implode the values into a comma separated values string. The groups-catalog extension simply needs a list of customer group ids (or the reserved "special" negative values), it doesn't make any sense to use strings that would be valid XML node names as the array keys. Please contact the implementors of the XML export extension and ask them to properly handle the attribute value. Checking if an array uses strings as the array keys or uses index numbers is a rather common task in PHP, and a google search comes up with many possible sollutions, e.g.:

function is_assoc($array) {
  return (bool)count(array_filter(array_keys($array), 'is_string'));
}