0

I am trying to override Magento Framework Feed.php file,

After googling alot I found how to override framework file but that's not worked for me.

Please give me the right eay to override framework feed file.

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="Serole\Corefiles\App\Feed" />
</config>

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;

/**
 * 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
    {
        echo '<pre>'; print_r($this->feeds); die();
        return FeedFactory::factory($this->feeds)->export(FeedFactoryInterface::FORMAT_RSS);
    }
}

Please guide me.

1 Answer 1

0

The process which I follwed in my question is correct, it started working with this solution,

I was trying to override it in an existing module where I did other functionalities, but when I create a new module for overriding, it worked there. I don't know the difference between both of those modules but it solved my problem.

This answer is strange but it worked for me.

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.