You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a small bug in the yotpoUtils.js file that causes the function getRatingsOrReviewsData() to return an empty object when there is no Primary Category on a Product. The current check cat.parent != null fails if cat itself is null.
Current Code while (cat.parent != null) { if (cat.online) { path[0] = cat.getDisplayName(); } cat = cat.parent; }
Issue
The condition cat.parent != null does not account for the case when cat is null. This can lead to an error and cause the function getRatingsOrReviewsData() to return an empty object.
Proposed Fix
Update the while loop condition to check if cat is not null before accessing cat.parent. This ensures that the loop only executes when cat is a valid object.
With this change, the productCategory will be empty if cat is null, but all other data will remain intact. This prevents the function from returning an empty object.
The text was updated successfully, but these errors were encountered:
There is a small bug in the
yotpoUtils.js
file that causes the functiongetRatingsOrReviewsData()
to return an empty object when there is no Primary Category on a Product. The current checkcat.parent != null
fails ifcat
itself isnull
.Affected File
salesforce-cartridge/cartridges/int_yotpo_sfra/cartridge/scripts/utils/yotpoUtils.js
Line 55 in 10b563b
Current Code
while (cat.parent != null) { if (cat.online) { path[0] = cat.getDisplayName(); } cat = cat.parent; }
Issue
The condition
cat.parent != null
does not account for the case whencat
isnull
. This can lead to an error and cause the functiongetRatingsOrReviewsData()
to return an empty object.Proposed Fix
Update the while loop condition to check if cat is not null before accessing cat.parent. This ensures that the loop only executes when cat is a valid object.
Suggested Code Change
while (cat && cat.parent != null) { if (cat.online) { path[0] = cat.getDisplayName(); } cat = cat.parent; }
With this change, the
productCategory
will be empty ifcat
isnull
, but all other data will remain intact. This prevents the function from returning an empty object.The text was updated successfully, but these errors were encountered: