Question

I am trying to get rss feed for coupon code,

Rss Feed for New Products, Special Products and all categories is working fine but not working for coupon code, I tried it on multiple magento installation but for coupon code it is not working anywhere.

The error which I am getting is: enter image description here

Please help me with this.

Was it helpful?

Solution 2

This solution worked for me:

In case of generating Coupon code RSS Feed, magento generate wrong array so it didn't convert in xml that's why I was getting that error.

Solution:

app/code/Vendor/Namespace/etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Framework\App\Feed" type="Vendor\Namespace\App\Feed" />
</config>

app/code/Vendor/Namespace/App/Feed.php

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Vendor\Namespace\App;

use Zend\Feed\Writer\FeedFactory;
use Magento\Framework\App\FeedFactoryInterface;

/**
 * Default XML feed class
 */
class Feed extends \Magento\Framework\App\Feed
{
    /**
     * @var array
     */
    private $feeds;

    /**
     * Feed constructor.
     * @param array $data
     */
    public function __construct(array $data)
    {
        $this->feeds = $data;
    }

    /**
     * {@inheritdoc}
     */
    public function getFormattedContent() : string
    {
        if(strpos($_SERVER['REQUEST_URI'], 'discounts') !== false){
            $feedData = $this->feeds;
            $feedData['title'] = 'My Title - Discounts and Coupons';
            $feedData['description'] = 'My Title - Discounts and Coupons';
            $this->feeds = $feedData;
        }
        return FeedFactory::factory($this->feeds)->export(FeedFactoryInterface::FORMAT_RSS);
    }
}

OTHER TIPS

I am running into the same issued. There is solution listed in GitHub: https://github.com/magento/magento2/pull/25320

These are the links to the files you need to modify.

https://github.com/magento/magento2/pull/25320/commits/05b1f8f00df227a36815353ff3e0c97fab96e626

https://github.com/magento/magento2/pull/25320/commits/752b609368babb8aa9139c62a39ccb04261762ce

I can confirm that the changes worked for Magento 2.3. Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top