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? – Amit Bera Nov 21 '19 at 7:16
  • actually when I click on save attribute, not works. it means this code does not override. – sarvesh Dineshkumar Patel Nov 21 '19 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. – sarvesh Dineshkumar Patel Nov 21 '19 at 9:42
  • is there any solution for this? – sarvesh Dineshkumar Patel Nov 21 '19 at 13:54
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>
4
  • thanks but not working – sarvesh Dineshkumar Patel Nov 21 '19 at 7:04
  • Is your module showing in the list after running the command: php bin/magento module:status – Vishal Nov 21 '19 at 9:20
  • thanks, yes, it is. – sarvesh Dineshkumar Patel Nov 21 '19 at 9:41
  • @Vishal I've fixed a typo for the for="" attribute – DRC May 14 '20 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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