magenxcommerce / module-product-alert-graph-ql
GraphQL coverage for the Magento_ProductAlert module: price/stock alert subscriptions for logged-in customers.
Package info
github.com/magenxcommerce/module-product-alert-graph-ql
Type:magento2-module
pkg:composer/magenxcommerce/module-product-alert-graph-ql
Requires
- php: ~8.3.0||~8.4.0||~8.5.0
- magento/framework: *
- magento/module-catalog: *
- magento/module-catalog-graph-ql: *
- magento/module-customer: *
- magento/module-customer-graph-ql: *
- magento/module-graph-ql: *
- magento/module-product-alert: *
- magento/module-store: *
- magento/module-store-graph-ql: *
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-24 19:35:41 UTC
README
Built with AI assistance. This module is built with significant use of Claude Code, under active human review and guidance. It is open source and in active development. AI assistance does not lower the engineering bar: every change must meet the same correctness, security, documentation and maintainability requirements as any other contribution.
No warranty. We are not responsible for any incompatibility. By installing this software, you accept responsibility for its security, upgrades, patches and monitoring.
GraphQL coverage for the stock Magento_ProductAlert module. It lets a
logged-in customer subscribe to price-drop and back-in-stock alerts and
read/manage their subscriptions — the same data the storefront controllers
(productalert/add/price, productalert/add/stock, productalert/unsubscribe/*)
write, exposed over GraphQL so a headless storefront can use it.
This is a companion module (like CatalogGraphQl beside Catalog); the core
Magento_ProductAlert module is left untouched.
Schema
Mutations
productAlertSubscribe(input: { product_sku: String!, alert_type: PRICE|STOCK }): ProductAlertSubscriptionOutput productAlertUnsubscribe(input: { product_sku: String!, alert_type: PRICE|STOCK }): ProductAlertSubscriptionOutput
Both require an authenticated customer (Authorization: Bearer <customer token>)
and operate on the current store/website (from the Store request header).
productAlertSubscribe throws if the alert type is disabled in
Stores → Configuration → Catalog → Catalog → Product Alerts. Subscribing
is idempotent; unsubscribing removes the alert in the current website and is a
no-op when there is none.
The output carries product_sku, alert_type and is_subscribed (the new
state, no extra query). Its product_alerts field returns the customer's full,
updated subscription list, but it loads every subscribed product, so select it
only when the whole list is needed (not for a product page toggle).
Queries
productAlertStatus(product_sku: String!): ProductAlertStatusOutput # { product_sku, is_price_alert_subscribed: Boolean!, is_stock_alert_subscribed: Boolean! }
Per-product subscription state for the product page buttons. Customer token required. One SKU lookup and one query over both alert tables, no catalog search or product load. An unknown SKU, or one not sold on the current website, reads as not subscribed.
customer { product_alerts { price_alerts { id alert_type price current_price price_diff add_date status status_changed_at product { ...ProductInterface } } stock_alerts { id alert_type add_date status status_changed_at product { ...ProductInterface } } } }
The product field resolves a full ProductInterface, so the storefront can
render product cards directly from the subscription list. Products are loaded
in one collection per store for the whole list, not one by one.
status is ACTIVE until the Magento_ProductAlert cron sends the
notification, then flips to SENT; status_changed_at is the date that
happened (last_send_date / send_date), null while still ACTIVE. On
price alerts, price is the price recorded when the customer subscribed,
current_price is the product's live price, and price_diff is
price - current_price (positive once the price has dropped).
StoreConfig fields
type StoreConfig { product_alert_allow_price: Boolean # catalog/productalert/allow_price product_alert_allow_stock: Boolean # catalog/productalert/allow_stock }
The StoreConfig flags let the storefront hide a subscribe button when the
merchant has disabled that alert type.
ProductInterface.is_price_alert_subscribed / is_stock_alert_subscribed were
removed in 2.0.0: they ran through the products search and became a per-item
query fan-out on any listing. Use productAlertStatus instead.
Install
Place the module under app/code/Magento/ProductAlertGraphQl (or install via
Composer), then:
bin/magento module:enable Magenx_ProductAlertGraphQl
bin/magento setup:upgrade
bin/magento setup:di:compile # production mode
bin/magento cache:flush
No DB schema changes — it reuses the existing product_alert_price /
product_alert_stock tables. Emails are still sent by the stock
Magento_ProductAlert cron (bin/magento cron:run), unchanged.