How ribog-digital/magento2-module-offers-page works
Project type and purpose
• This is a Magento 2 module (extension) named Ribog_Offers.
• Purpose: Provide a dedicated frontend “Offers” page and backend configuration to display active catalog and cart price rules marked “Visible on Offer Page.”
File structure
• Top-level Magento module layout:
• Block/Index – frontend block classes
• Controller/Index – frontend controllers for the /offers route
• Model/Config (and Source/Promotions) – config helpers and data sources
• etc/ – routing (frontend/routes.xml), admin config (adminhtml/system.xml), module.xml, ACL, DB schema
• view/frontend – layout XML, templates, CSS, JS for the user-facing Offers page
• view/adminhtml – UI Component XML to add “Visible on Offer Page” toggle in rule edit forms
• No custom database tables; module uses Magento’s catalogrule and salesrule tables plus core_config_data.
README for additional insights
• Lists features (Offers page, toggle in price rule forms, enable/disable via system config).
• Describes user flows for admin configuration and frontend access at /offers.
Main components and interactions
a. Frontend flow
• Web Client (Browser)
→ HTTP GET /offers
→ Magento Front Controller (index.php → router)
→ Ribog_Offers\Controller\Index\Index
→ Block\Index\Index (viewModel)
→ Template view/frontend/templates/index/index.phtml
→ CSS (view/frontend/web/css) & JS (offers.js)
→ Rendered HTML/CSS/JS back to Browser
→ Browser displays the list of promotions (fetched from Model\Source\Promotions)
b. Backend (Admin) flow
• Magento Admin UI
→ UI Component form definitions (view/adminhtml/ui_component/*.xml)
→ Adds “Visible on Offer Page” attribute to Catalog & Cart Price Rule edit screens
→ Form submission writes attribute to salesrule/catalogrule tables via Magento ORM
→ Module’s etc/adminhtml/system.xml exposes global enable/disable flag stored in core_config_data
c. Data / Persistence
• Magento MySQL Database
– salesrule, catalogrule tables (with new attribute)
– core_config_data (module on/off flag and include promotions setting)
Architectural patterns and design principles
• Follows Magento 2 MVC: Controllers → Blocks → Templates
• Leverages Magento UI Component framework in adminhtml
• Uses Dependency Injection (via constructor arguments in PHP classes)
• Configuration via etc/*.xml (routes.xml, module.xml, system.xml, acl.xml)
• No heavy business logic—primarily a presentation and configuration extension