# Flat File Listings

## Usage

To convert a `POST_FLAT_FILE_LISTINGS_DATA` feed to the newer `JSON_LISTINGS_FEED` format:

```php
use SellingPartnerApi\FeedTransformer\Transformer;
use SellingPartnerApi\FeedTransformer\FeedTypes\Listings;

$feedFile = 'path/to/your/feed.tab';
$json = Transformer::fromFile(
    Listings::$feedType,
    $feedFile,
    'ATVPDKIKX0DER'
);

$jsonFeedPath = 'path/to/new/feed.json';
file_put_contents($jsonFeedPath, json_encode($json));
```

***The first time using this feed transformer with a particular product type, we strongly recommend running the converted data through*** [***our validators***](https://docs.highsidelabs.co/feed-transformer/validation) ***before putting it into production.*** That way, you can ensure you know if certain elements of your feed aren't able to be mapped to the new format.

### Parameters <a href="#parameters" id="parameters"></a>

### `merchantId`

{% hint style="danger" %}
**Required**
{% endhint %}

There is documentation on how to retrieve your `merchantId`  in the [#common-required-parameters](https://docs.highsidelabs.co/feed-transformer/feed-types/tab/..#common-required-parameters "mention")section of the [](https://docs.highsidelabs.co/feed-transformer/feed-types/tab "mention") page.

### `shippingGroupMap` <a href="#shippinggroupmap" id="shippinggroupmap"></a>

{% hint style="warning" %}
Required if the `merchant_shipping_group_name` column is present in the feed file being converted.
{% endhint %}

This is a mapping of your account's shipping group names to their internal Amazon identifiers. Instructions on how to generate this mapping are here: [shippingGroupMap](https://docs.highsidelabs.co/feed-transformer/feed-types/tab/invloader#shippinggroupmap)

### `onUnsupportedField` <a href="#onunsupportedfield" id="onunsupportedfield"></a>

{% hint style="info" %}
Optional. Default `fail`.
{% endhint %}

This option controls what happens when the feed transformer encounters an XML tag that has no direct equivalent in the new JSON format. There are two accepted values:

* `ignore`: Silently move past un-mappable XML tags.
* `callback`: Pass un-mappable XML fields (by [xpath](https://developer.mozilla.org/en-US/docs/Web/XPath)) to a user-defined callback. See [callback](https://docs.highsidelabs.co/feed-transformer/feed-types/xml/product#callback)
* `fail`: The first time an un-mappable XML tag is encountered, throw an `InvalidFeedException`. This is the default.

### `callback` <a href="#callback" id="callback"></a>

{% hint style="info" %}
Conditionally required if `onSupportedField` is set to `callback` .
{% endhint %}

This option is the callback to be called if `onSupportedField` is set to `callback` and an un-mappable XML field is encountered while processing the input data. The callback's signature is `fn (string): void`. For example:

```php
$options = [
    'onUnsupportedField' => 'callback',
    'callback' => function ($field) {
        echo "Unsupported field: $field";
        // -> Unsupported field: unsupported_field_name
    },
    // ...
];
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.highsidelabs.co/feed-transformer/feed-types/tab/listings.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
