> For the complete documentation index, see [llms.txt](https://docs.fact-finder.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fact-finder.com/magento/sdk-v5.x/modification-and-troubleshooting.md).

# Modification and troubleshooting

The Magento 2 module integrates with the default Luma theme. Most projects need customizations.

## Changing existing column names

Column names are defined in `etc/di.xml`. Change the column definition, then replace the standard name in a DataProvider plugin.

```xml
<virtualType name="Omikron\Factfinder\Model\Export\CatalogFeed">
    <arguments>
        <argument name="columns" xsi:type="array">
            <item name="Master" xsi:type="string">CUSTOM_NAME</item>
        </argument>
    </arguments>
</virtualType>
```

```xml
<type name="Omikron\Factfinder\Model\Export\Catalog\ProductType\SimpleDataProvider">
    <plugin name="custom-provider" type="YOUR_VENDOR\YOUR_MODULE\Plugin\AfterToArrayPlugin" />
</type>
```

```php
public function afterToArray($subject, $result)
{
    return ['CUSTOM_NAME' => $result['Master']] + $result;
}
```

Magento merges DI definitions, so do not copy unrelated entries. Then run:

```
bin/magento cache:clean config
```

## Adding a new column

`FieldProvider` defines fields requiring logic beyond retrieving product data:

```xml
<type name="Omikron\Factfinder\Model\Export\Catalog\FieldProvider">
    <arguments>
        <argument name="productFields" xsi:type="array">
            <item name="ImageURL" xsi:type="object">Omikron\Factfinder\Model\Export\Catalog\ProductField\ProductImage</item>
            <item name="CategoryPath" xsi:type="object">Omikron\Factfinder\Model\Export\Catalog\ProductField\CategoryPath</item>
            <item name="Attributes" xsi:type="object">Omikron\Factfinder\Model\Export\Catalog\ProductField\Attributes</item>
        </argument>
    </arguments>
</type>
```

To export a `BrandLogo` image URL, add a field definition. Your exporter must implement `Omikron\Factfinder\Api\Export\FieldInterface`:

```php
class BrandLogo implements \Omikron\Factfinder\Api\Export\FieldInterface
{
    public function getValue(Product $product): string
    {
        // Get the product brand logo URL.
    }
}
```

Define the column in `CatalogFeed`:

```xml
<virtualType name="Omikron\Factfinder\Model\Export\CatalogFeed">
    <arguments>
        <argument name="columns" xsi:type="array">
            <item name="BrandLogo" xsi:type="string">BrandLogo</item>
        </argument>
    </arguments>
</virtualType>
```

### GenericField usage

For a direct product attribute, use a `GenericField` virtual type:

```xml
<virtualType name="Omikron\Factfinder\Model\Export\Catalog\ProductField\Brand" type="Omikron\Factfinder\Model\Export\Catalog\ProductField\GenericField">
    <arguments>
        <argument name="attributeCode" xsi:type="string">manufacturer</argument>
    </arguments>
</virtualType>
```

Run `bin/magento cache:clean config` after the change.

## Adding a custom product data provider

Map a custom product type to a data provider through Magento DI:

```xml
<type name="Omikron\Factfinder\Model\Export\Catalog\DataProvider">
    <arguments>
        <argument name="entityTypes" xsi:type="array">
            <item name="customProductType" xsi:type="string">YOUR_VENDOR\YOUR_MODULE\Model\Export\Catalog\ProductType\CustomDataProvider</item>
        </argument>
    </arguments>
</type>
```

```php
<?php
class CustomDataProvider implements DataProviderInterface
{
    /** @var Product */
    protected $product;

    public function __construct(Product $product)
    {
        $this->product = $product;
    }

    public function getEntities(): iterable
    {
        // Your logic.
    }
}
```

Magento passes `$product` automatically. Implement `getEntities` to return the required data.

## Exporting fields from variants

By default, the module exports configurable product data. Variants override only selected fields. Review `src/Model/Export/Catalog/Entity/ProductVariation.php`.

Use `variantFields` when variants need additional exported fields. This example exports `ImageURL` from variants:

```xml
<type name="Omikron\Factfinder\Model\Export\Catalog\FieldProvider">
    <arguments>
        <argument name="productFields" xsi:type="array">
            <item name="CategoryPath" xsi:type="object">Omikron\Factfinder\Model\Export\Catalog\ProductField\CategoryPath</item>
            <item name="Brand" xsi:type="object">Omikron\Factfinder\Model\Export\Catalog\ProductField\Brand</item>
            <item name="FilterAttributes" xsi:type="object">Omikron\Factfinder\Model\Export\Catalog\ProductField\FilterAttributes</item>
        </argument>
        <argument name="variantFields" xsi:type="array">
            <item name="ImageURL" xsi:type="object">Omikron\Factfinder\Model\Export\Catalog\ProductField\ProductImage</item>
        </argument>
    </arguments>
</type>
```

## Troubleshooting

#### Removing `/pub` from exported URLs

If the feed exports URLs containing `pub/`, your document root likely points to `/pub`. Add this entry to your project's `env.php`:

```php
'directories' => [
    'document_root_is_pub' => true
],
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.fact-finder.com/magento/sdk-v5.x/modification-and-troubleshooting.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
