Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

https://github.com/magesuite/back-in-stock

It allows to receive email notifications when a product is again in stock. Can be extended with Magesuite_PwaNotifications and Magesuite_BackInStockPwaNotifications

Installation

This module is optional

composer require "creativestyle/magesuite-back-in-stock" ^1.0.0

User manual

4.4.Back-In-Stock Subscriptions

Admin settings

In order to activate this module go to:

Stores -> Configuration -> Magesuite -> Back in Stock Subscriptions and select Yes in the Enabled dropdown. With its activation additional tab Back in stock can be found on every product detail page.

Above there are also a few optional settings visible above - they are well described and can be adjusted per clients request.

Another set of settings are available in Email Configuration - they’re described in user manual linked above.

Frontend

In the buybox short form for subscribing to back-in-stock email notifications is displayed.

When confirmation is required there is a message visible and email is being sent:

When confirmation is not required success message is displayed:

Logged-in users can unsubscribe from all back-in-stock notifications in the admin panel:

Once product is back in stock every subscriber will be notify by email. This action can be also triggered manually for every product on it’s page in admin panel.

Backend

Queue setup

This module depends on queue consumers being run constantly.

Queue name depends on environment configuration:

  • magesuite.consumer.db if RabbitMQ is not configured in app/etc/env.php

  • magesuite.consumer.amqp if RabbitMQ is configured in app/etc/env.php

Example of queue startup:

magesuite.consumer.db:

bin/magento queue:consumers:start magesuite.consumer.db

magesuite.consumer.amqp:

bin/magento queue:consumers:start magesuite.consumer.amqp

Cron

This module is using send_back_in_stock_notification_from_queue cron.

Its name is self-explanatory. It sends notifications about the items that are back in stock.

By default, it does so every minute, but it can be changed as we please in the admin panel.

We can also set if the subscription should be canceled after sending the first notification, by default, it is not canceled, so the customer will be receiving a notification every time a product will be back in stock unless he/she unsubscribes or we change settings.

Database changes

This module comes with 2 tables.

back_in_stock_subscription_entity

int "id" PRIMARY KEY
int "customer_id" NOT FOREIGN KEY (!)
varchar "customer_email" 
int "product_id" FOREIGN KEY
int "parent_product_id" NOT FOREIGN KEY (!)
smallint "store_id" FOREIGN KEY
timestamp "add_date"
timestamp "send_date"
smallint "send_count"
varchar "send_notification_status"
boolean "customer_confirmed"
boolean "customer_unsubscribed"
varchar "token"
varchar "notification_channel"
boolean "is_removed"

back_in_stock_notification_queue

int "id" PRIMARY KEY
int "subscribtion_id" FOREIGN KEY
varchar "notification_type"
text "message"

Subscription management from the user side

Both enabling and disabling subscription from the user side, is resolved by entering accordingly Subscribe and Unsubscribe controller via Ajax script.

Enabling

Controller/Notification/Subscribe.php which leads to Service\Subscription\Channel\Email\EmailSubscriptionCreator::subscribe

Disabling

Controller/Notification/Unsubscribe.php which leads to Model\BackInStockSubscription::setCustomerUnsubscribed

Plugins

This module comes with 3 plugins.

The first 2, are responsible for collecting back-in-stock items.

Plugin\Inventory\Model\SourceItem\Command\SourceItemsSave\CollectBackInStockItemsForQueue

Plugin\Inventory\Model\SourceItem\Command\SourceItemsSaveWithoutLegacySynchronization\CollectBackInStockItemsForQueue

The 3rd one adds them to the queue

Plugin\InventoryIndexer\Plugin\InventoryApi\ReindexAfterSourceItemsSavePlugin\AddBackInStockItemsToQueue

  • No labels