Announcement Bar

Description The Kowal_AnnouncementBar module adds an announcement bar in the store header (frontend) and an admin panel to manage announcement content, icon, and link. Rendering is global via the default.xml layout in the header.container, and rotation is handled by JS.

Who It’s For For e-commerce and marketing teams that want to manage short header messages without changing the theme code.

Features

  • Adds a frontend block Kowal\AnnouncementBar\Block\AnnouncementBar rendered in header.container on all pages via view/frontend/layout/default.xml and template view/frontend/templates/announcement_bar.phtml.
  • Displays announcements from the kowal_announcementbar_announcement table; currently there is no status filter (the filter line is commented out), so all records are rendered.
  • Supports an optional link in the announcement content and an icon; if no icon is set, it uses the default view/frontend/web/images/arrow.svg.
  • Rotates announcements in view/frontend/web/js/announcement.js with fadeIn/fadeOut animation; the number of visible items depends on viewport width (>=1024: 4, >=768: 2, otherwise 1) and is updated on resize.
  • Bar color configuration (background_color, font_color) is available in default/website/store view scope; values are fetched with ScopeInterface::SCOPE_STORE.
  • Admin UI (UI Component) with listing and form: grid kowal_announcementbar_announcement_listing, form kowal_announcementbar_announcement_form.
  • Admin CRUD operations: list, edit, save, delete, inline edit in the grid.
  • Icon upload in admin (kowal_announcementbar/announcement/upload) stores files under media/announcementbar/icons with dispersion and returns a public URL.
  • Declarative DB schema: table kowal_announcementbar_announcement with columns announcement_id, icon, content, status, link.

Installation * = in production please use the --keep-generated option

Type: Composer

  1. Add the composer repository to the configuration:

    
    composer config repositories.announcement.bar vcs https://github.com/kowalco/magento-2-announcement-bar
  2. Add an access token for the private GitLab repository:

    
    composer config --global --auth github-oauth.github.com <YOUR_TOKEN>
  3. Install the module using Composer:

    
    composer require kowal/module-announcementbar
  4. Enable the module:

    
    php bin/magento module:enable Kowal_AnnouncementBar
  5. Apply database updates:

    
    php bin/magento setup:upgrade
  6. Flush the cache:

    php bin/magento cache:flush

Configuration

  • Configuration path: Stores > Configuration > (tab: kowal) > Announcement Bar Settings > General Settings.
  • Fields:
    • kowal_announcementbar/general/background_color (hex, scope: default/website/store view).
    • kowal_announcementbar/general/font_color (hex, scope: default/website/store view).
  • Default values from etc/config.xml: #ffffff for background and #000000 for font color.

Deployment and Operations

  • The module adds CSS and JS in default.xml; in production mode you must deploy static content for view/frontend/web/css/source/_module.less and view/frontend/web/js/announcement.js to load.
  • Changes to announcements and configuration may require cache refresh (e.g., FPC/Block cache) because the bar is rendered in the header.
  • Icon upload stores files in media/announcementbar/icons — ensure backup/retention for this directory.

Deployment Checklist

  1. Ensure the kowal_announcementbar_announcement table is created after setup:upgrade.
  2. Verify color configuration is set for the correct scope (store view).
  3. Check that the announcement.bar block renders in the header and JS/CSS load.
  4. Test icon upload in admin and file availability in media/announcementbar/icons.
  5. Verify announcement rotation on desktop/tablet/mobile.

CI/CD and Environments

  • No dedicated CI/CD scripts in the module.
  • In the deployment pipeline, include standard Magento steps after module install/upgrade (DB upgrade, static content deploy in production, cache clean/flush).

Rollback

  • Disable the module: php bin/magento module:disable Kowal_AnnouncementBar.
  • Table/record removal is not automatic — an operational decision (manual DB cleanup) if rollback should remove data.
  • When rolling back from backup, keep media/announcementbar/icons consistent with DB records.

Requirements / Notes

  • No Magento or PHP version constraints declared in composer.json (require is empty) — compatibility must be confirmed in the target environment.
  • etc/acl.xml does not define Kowal_AnnouncementBar::root, Kowal_AnnouncementBar::config, or Kowal_AnnouncementBar::top_level, although they are referenced in menu.xml, system.xml, and Controller/Adminhtml/Announcement.php. This may cause permission/menu visibility issues.
  • In etc/adminhtml/menu.xml, the parent is Kowal_Base::kowal_modules, and in system.xml the tab kowal is used — these elements are not defined in this module.
  • The UI grid has a duplicated status column (two entries with the same name in kowal_announcementbar_announcement_listing.xml).
  • The status field exists in DB and grid but is commented out in the edit form.

Compatibility

  • Magento 2: not declared in module (to be confirmed).
  • PHP: not declared in module (to be confirmed).

FAQ

  • Why don’t I see the menu item or configuration in Admin? The module is missing ACL definitions for Kowal_AnnouncementBar::root, Kowal_AnnouncementBar::config, and Kowal_AnnouncementBar::top_level. This can block menu/config visibility.
  • Why is there no status filter on the frontend? In Block/AnnouncementBar.php, the status filter is commented out, so all records are rendered.
  • Why do the installation commands in README look incorrect? The Installation section in README has unclosed code fences. In item.md, the code block was closed after step 6 to keep the rest of the document readable, while keeping the same layout and commands.
  • What is the exact Composer package name? README uses kowal/module-announcementbar, while the module composer.json uses kowal/announcement-bar. This requires confirmation in the package repository.