Newsletter on Magento 2

Hi all,
by default Vue Storefront send the newsletter subscription to MailChimp:

"newsletter": {
   "endpoint": "/api/ext/mailchimp-subscribe/subscribe"
}

What do you recommend to connect the newsletter on Magento 2 instead of MailChimp?

By default we don’t have the integration with Magento newsletter feature. Please add the proposer vsfapi endpoint which will be using the newsletter endpoint from https://devdocs.magento.com/swagger/

Hi @pkarw,
I’ve created a module for VSF-API and M2 that enable the newsletter subscription to M2 through VSF.

Here is the code for VSF-API:

Here the M2 endpoint:

I think that, if it can be useful for the community, it could be added to the core of VSF.

Tell me if I can do anything useful for the VSF project.
Thanks!

1 Like

Just a FYI, we used your code but found out you need to have a couple more API calls for the account section to check the subscriber status and unsubscribe. If not you are going to get errors.

Here is the Magento code we added, still need to add some security around this though.

    /**
     * Returns user unsubscribed
     * @param string $email
     * @return string
     */
    public function unsubscribeByEmail($email)
    {
        $websiteID = $this->_storemanager->getStore()->getWebsiteId();
        $customer = $this->_customer->create()->setWebsiteId($websiteID)->loadByEmail($email);
        $customerId = $customer->getId();
        $this->subscriberFactory->create()->unsubscribeCustomerById($customerId);
        return "unsubscribed";
    }

     /**
     * Returns user status
     * @param string $email
     * @return string
     */
    public function subscribeStatusByEmail($email){
        $websiteID = $this->_storemanager->getStore()->getWebsiteId();
        $customer = $this->_customer->create()->setWebsiteId($websiteID)->loadByEmail($email);
        $customerId = $customer->getId();
        $subscriber = $this->subscriberFactory->create()->loadByCustomerId($customerId);
        $isSubscribed = $subscriber->isSubscribed();
        if($isSubscribed){
            return "subscribed";
        }else{
            return "";
        }
        
    }
1 Like

Hi @darkentity and thank you for your feedback and the code you shared with us.
As you can see, we plan to add this feature, but we haven’t had the time to do it at the moment:

If in the meantime you develop this feature it’d be great if you contribute to this module doing a pull request on GitHub :slight_smile:

@rozzilla can you please help me with the same?

Hello @Hamendra_Sunthwal please refer to this comment:

To use the Magento 2 newsletter on Vue Storefront, you need to install these 2 modules: one on Magento 2, the other one on the VSF API.

You can find all the instructions about the installation on GitHub.

Hello @rozzilla , can you please take a look here ?

Thankyou

I’ve seen it and it’s not about the newsletter, but the wishlist. Currently I don’t know how to help you about the wishlist.

I’ve added the GET & POST endpoint and I’ve also added the support for the Google reCaptcha validation.

1 Like

I’ve added the newsletter integration also for Magento 1.

The 2 modules are available on GitHub:

1 Like

Looks great, thanks @rozilla

1 Like

Roberto, Great work! @rozzilla

1 Like

Thanks! :slight_smile: