Skip to content

Commit

Permalink
LPS-141044 Fix send notifications to use correct group and channel
Browse files Browse the repository at this point in the history
  • Loading branch information
joseabelenda committed Oct 19, 2021
1 parent bbb4fc8 commit a843a70
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package com.liferay.commerce.internal.model.listener;

import com.liferay.commerce.notification.util.CommerceNotificationHelper;
import com.liferay.commerce.product.model.CommerceChannel;
import com.liferay.commerce.product.service.CommerceChannelLocalService;
import com.liferay.object.model.ObjectDefinition;
import com.liferay.object.model.ObjectEntry;
import com.liferay.object.service.ObjectDefinitionLocalService;
Expand Down Expand Up @@ -64,12 +66,20 @@ public void onAfterUpdate(

private void _sendNotifications(String action, ObjectEntry objectEntry) {
try {
CommerceChannel commerceChannel =
_commerceChannelLocalService.fetchCommerceChannelBySiteGroupId(
objectEntry.getGroupId());

if (commerceChannel == null) {
return;
}

ObjectDefinition objectDefinition =
_objectDefinitionLocalService.getObjectDefinition(
objectEntry.getObjectDefinitionId());

_commerceNotificationHelper.sendNotifications(
objectEntry.getGroupId(), objectEntry.getUserId(),
commerceChannel.getGroupId(), objectEntry.getUserId(),
objectDefinition.getClassName() + "#" + action, objectEntry);
}
catch (PortalException portalException) {
Expand All @@ -82,6 +92,9 @@ private void _sendNotifications(String action, ObjectEntry objectEntry) {
private static final Log _log = LogFactoryUtil.getLog(
ObjectEntryModelListener.class);

@Reference
private CommerceChannelLocalService _commerceChannelLocalService;

@Reference
private CommerceNotificationHelper _commerceNotificationHelper;

Expand Down

0 comments on commit a843a70

Please sign in to comment.