0

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.

2 Answers 2

0

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.

0

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);
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.