Skip to main content
Some Mistakes and More Explainatory
Source Link

First you have to Override your Existing File so basically you need to follow such simple steps:

  1. Create Module OSCP_NewsletterOveride - Path: app/code/OSCP/NewsletterOveride
  2. Create module.xml file in path app/code/OSCP/NewsletterOveride/etc/module.xml

and paste this code

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="OSCP_NewsletterOveride" setup_version="1.0.0">
    </module>
</config>
  1. Create etc/registration.php file -path: app/code/OSCP/NewsletterOveride/registration.php

and paste this code

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'OSCP_NewsletterOveride',
    __DIR__
);
  1. Now Enable the Module with command:php bin/magento module:enable OSCP_NewsletterOveride

  2. This way you can create your Module.

Now Override Newsletter File

Create File URL/newsletter/edit/

Now you need to Override file by Creating di.xmlCreate newsletter_edit_index.xml in etc folder. Set PreferencesPath: app/code/OSCP/NewsletterOveride/view/frontend/layout/newsletter_edit_index.xml

and Override File.Add following code:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <update handle="customer_account"/>
    <body>
        <referenceContainer name="content">
            <block class="Magento\Customer\Block\Newsletter" name="customer_newsletter_form" template="OSCP_NewsletterOverride::form/newsletter.phtml">
                <container name="customer.newsletter.form" as="form_override" label="Newsletter Subscription" htmlTag="div" htmlClass="newsletter_form"/>
            </block>
        </referenceContainer>
    </body>
</page>

Now copy your original newsletter file in following Path: app/code/OSCP/NewsletterOveride/view/frontend/templates/form/newsletter.phtml

Hope this will help you!!

First you have to Override your Existing File so basically you need to follow such simple steps:

  1. Create Module OSCP_NewsletterOveride - Path: app/code/OSCP/NewsletterOveride
  2. Create module.xml file in path app/code/OSCP/NewsletterOveride/etc/module.xml

and paste this code

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="OSCP_NewsletterOveride" setup_version="1.0.0">
    </module>
</config>
  1. Create etc/registration.php file -path: app/code/OSCP/NewsletterOveride/registration.php

and paste this code

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'OSCP_NewsletterOveride',
    __DIR__
);
  1. Now Enable the Module with command:php bin/magento module:enable OSCP_NewsletterOveride

  2. This way you can create your Module.

Now you need to Override file by Creating di.xml in etc folder. Set Preferences and Override File.

First you have to Override your Existing File so basically you need to follow such simple steps:

  1. Create Module OSCP_NewsletterOveride - Path: app/code/OSCP/NewsletterOveride
  2. Create module.xml file in path app/code/OSCP/NewsletterOveride/etc/module.xml

and paste this code

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="OSCP_NewsletterOveride" setup_version="1.0.0">
    </module>
</config>
  1. Create etc/registration.php file -path: app/code/OSCP/NewsletterOveride/registration.php

and paste this code

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'OSCP_NewsletterOveride',
    __DIR__
);
  1. Now Enable the Module with command:php bin/magento module:enable OSCP_NewsletterOveride

  2. This way you can create your Module.

Now Override Newsletter File

Create File URL/newsletter/edit/

Now Create newsletter_edit_index.xml in Path: app/code/OSCP/NewsletterOveride/view/frontend/layout/newsletter_edit_index.xml

and Add following code:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <update handle="customer_account"/>
    <body>
        <referenceContainer name="content">
            <block class="Magento\Customer\Block\Newsletter" name="customer_newsletter_form" template="OSCP_NewsletterOverride::form/newsletter.phtml">
                <container name="customer.newsletter.form" as="form_override" label="Newsletter Subscription" htmlTag="div" htmlClass="newsletter_form"/>
            </block>
        </referenceContainer>
    </body>
</page>

Now copy your original newsletter file in following Path: app/code/OSCP/NewsletterOveride/view/frontend/templates/form/newsletter.phtml

Hope this will help you!!

Source Link

First you have to Override your Existing File so basically you need to follow such simple steps:

  1. Create Module OSCP_NewsletterOveride - Path: app/code/OSCP/NewsletterOveride
  2. Create module.xml file in path app/code/OSCP/NewsletterOveride/etc/module.xml

and paste this code

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="OSCP_NewsletterOveride" setup_version="1.0.0">
    </module>
</config>
  1. Create etc/registration.php file -path: app/code/OSCP/NewsletterOveride/registration.php

and paste this code

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'OSCP_NewsletterOveride',
    __DIR__
);
  1. Now Enable the Module with command:php bin/magento module:enable OSCP_NewsletterOveride

  2. This way you can create your Module.

Now you need to Override file by Creating di.xml in etc folder. Set Preferences and Override File.