0

I am trying to create a module in which I am facing some issues to override Save.php Controller as well as save that data in the new table. enter image description here

here is my updated di.xml code, but now after click on save, the redirect URL is blank.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
   <preference for="Magento\Catalog\Controller\Adminhtml\Product\Attribute\Save" type="Lucent\LiTab\Controller\Adminhtml\Product\Attribute\Save" />
</config>

and my controller code for override is

<?php
/**
 *
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

namespace Lucent\LiTab\Controller\Adminhtml\Product\Attribute;

class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Attribute\Save
{
    public function execute()
    {
        $data = $this->getRequest()->getPostValue();
        print_r($data);
        die();
    }
}

So please let me know where I did wrong code.

Please give me a solution for this!

4
  • Have u check that $this->getRequest()->getPostValue() field is gives your custom field value? Commented Nov 21, 2019 at 7:16
  • actually when I click on save attribute, not works. it means this code does not override. Commented Nov 21, 2019 at 7:23
  • @AmitBera I Updated code I get a response for that field but error to not redirect that attribute page some error comes. Commented Nov 21, 2019 at 9:42
  • is there any solution for this? Commented Nov 21, 2019 at 13:54

1 Answer 1

1

di.xml is incorrect. Please try this

<?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\Catalog\Controller\Adminhtml\Product\Attribute\Save" type="Vendor\Module\Controller\Catalog\Adminhtml\Product\Attribute\Save" />
</config>
2
  • Is your module showing in the list after running the command: php bin/magento module:status Commented Nov 21, 2019 at 9:20
  • @Vishal I've fixed a typo for the for="" attribute Commented May 14, 2020 at 17:11

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.