Open chrisaligent opened 2 years ago
I was fairly easily able to prototype a Slider for announcements, although this would require additional frontend development to finish off.
Rather than using System Configuration for these Announcements, they may be best moved to a new Entity (ie AligentAnnouncement
).
Each Announcement should include:
@ORM\Column(type="wysiwyg", nullable=true)
)(Later, additional settings can be added, e.g. #10, #11 ).
We may also be able to add more announcement positions in future, such as "top of page", "below nav menu", "in checkout", "in category/webcatalog node", "above shipping methods", "above payment methods", etc.
The System Configuration can be used for:
The "Background colour" setting would instead become part of the WYSIWYG content itself, eg:
(This would allow us to render previews in the admin panel if needed)
AligentAnnouncement
entityAnnouncementProvider
(to return all applicable Announcements based on above criteria, sorted by priority)AnnouncementProvider
) with getActiveAnnouncements
(and hasActiveAnnouncements
?) methodsvendor/oro/commerce/src/Oro/Bundle/CMSBundle/Resources/views/layouts/blank/content_block.html.twig
)I have completed adding the new AligentAnnouncement
Entity. Instead of using startDate
and endDate
, I have used the Oro ScheduleIntervalInterface
on a linked entity called AligentAnnouncementSchedule
, which will let us use a filtration service to filter to active Announcements.
I have also used Oro scopes (Oro\Bundle\ScopeBundle\Entity\Scope
) to restrict to Customer
, CustomerGroup
, and/or Website
(if on Enterprise Edition). This should allow Oro to do most of the heavy lifting here.
Additionally the Announcements are now Organization-scoped as is Oro best practice. Changes pushed to https://github.com/aligent/orocommerce-announcement-bundle/tree/feature/multiple-announcement-boilerplate
Proceeding to work on CRUD UI as this will determine how much effort may be needed to use Scopes/Schedules.
I now have scheduled Announcements working. I have tested this by adding multiple Schedules to an Announcement: I loaded the page at 4:56pm and the announcement was visible. At 4:47pm it disappeared. It reappeared at 5:01pm. I changed my User Configuration to a different timezone and confirmed that the Schedule updated to match my local time (from 4:57pm to 5:27pm), which confirms that schedules are being stored/managed in UTC:
Multiple Announcements are displayed as expected:
However, Scopes are unreliable. Oro doesn't seem to like setting multiple Scopes, only the first Scope appears to be used. So setting an Announcement to be visible by multiple Customer Groups does not work (ie "x OR y" instead of "x AND y"). So this will take additional effort to resolve, I'm unsure how this works in other parts of the Oro codebase (eg Pages, Promotions etc).
Currently it's only possible to have a single Announcement running at a time.
So it's not possible to have different Announcements for Guests vs Logged-In Customers, or a specific Customer Group.
It should be possible to setup multiple announcements with different criteria, essentially making the current Configuration settings part of a Configuration Collection. The Layout DataProvider can load the configuration and determine which Announcements to display to the current Customer.
However this presents a challenge, if the DataProvider returns multiple applicable Announcements then it will break the template.
So, a decision needs to first be made as to whether we should: