1

I have created module for newsletter extra fields.In my module plugin file is not working pls someone help me


My plugin path is Vendor/Module/Plugin/Newsletter
and my code is

namespace Vendor\Module\Plugin\Newsletter;

use Magento\Framework\App\Request\Http;

class Subscriber {
  protected $request;

  public function __construct(
    Http $request
  ) {
    $this->request = $request;
  }
  public function aroundSubscribe($subject, \Closure $proceed, $email) {
    $result = $proceed($email);
    if ($this->request->isPost() && $this->request->getPost('firstname')) {
      $firstname = $this->request->getPost('firstname');
      $lastname = $this->request->getPost('lastname');
      $gender = $this->request->getPost('gender');

      $subject->setCFirstname($firstname);
      $subject->setCLastname($lastname);
      $subject->setGender($gender);

      try {
        $subject->save();
      }catch (\Exception $e) {
        throw new \Exception($e->getMessage());
      }
    }

    return $result;
  }
}
  • For which class you want to use aroung – Amit Bera Aug 24 '17 at 11:09

Your Answer

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

Browse other questions tagged or ask your own question.