Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YTPOS-125 adjusted name to get correct site preference value #23

Open
wants to merge 1 commit into
base: release/21.6.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function setYotpoConfigOverrides(locale) {
enableRatings: currSite.getCustomPreferenceValue('enableRatings') || false,
isRatingsEnabled: currSite.getCustomPreferenceValue('enableRatings') || false,

productInformationFromMaster: currSite.getCustomPreferenceValue('productInformationFromMaster') || false,
yotpoProductInformationFromMaster: currSite.getCustomPreferenceValue('yotpoProductInformationFromMaster') || false,

yotpoLoyaltyEnabled: currSite.getCustomPreferenceValue('yotpoLoyaltyEnabled') || false,
isLoyaltyEnabled: currSite.getCustomPreferenceValue('yotpoLoyaltyEnabled') || false,
Expand Down Expand Up @@ -134,8 +134,8 @@ function setYotpoConfigOverrides(locale) {
if ('enablePurchaseFeed' in localeConfigObject.custom) {
yotpoConfig.enablePurchaseFeed = localeConfigObject.custom.enablePurchaseFeed;
}
if ('productInformationFromMaster' in localeConfigObject.custom) {
yotpoConfig.productInformationFromMaster = localeConfigObject.custom.productInformationFromMaster;
if ('yotpoProductInformationFromMaster' in localeConfigObject.custom) {
yotpoConfig.yotpoProductInformationFromMaster = localeConfigObject.custom.yotpoProductInformationFromMaster;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, the localeConfigObject originates from Custom Object with type-id=yotpoConfiguration. That Custom Object defined in Metadata\metadata\meta\custom-objecttype-definitions.xml has no definition for the attribute yotpoProductInformationFromMaster (and no trace of the old attribute productInformationFromMaster). While this is safe code because of the in check, these lines will never be hit unless the actual object definition is updated.

}
if ('yotpoLoyaltyEnabled' in localeConfigObject.custom) {
yotpoConfig.yotpoLoyaltyEnabled = yotpoConfig.isLoyaltyEnabled = localeConfigObject.custom.yotpoLoyaltyEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
function getExportOrderConfig() {
var Site = require('dw/system/Site');
return {
productInformationFromMaster: Site.getCurrent().getPreferences().custom.yotpoProductInformationFromMaster,
yotpoProductInformationFromMaster: Site.getCurrent().getPreferences().custom.yotpoProductInformationFromMaster,
exportGroupIdInOrder: Site.getCurrent().getPreferences().custom.yotpoExportGroupIdInOrder
};
}
Expand Down Expand Up @@ -504,7 +504,7 @@ function prepareOrderProductsData(order) {
throw new Error(constants.EXPORT_ORDER_MISSING_PRODUCT_ERROR + ' Product ID: ' + productLineItem.productID);
}

if (exportOrderConfig.productInformationFromMaster && currentProduct.variant) {
if (exportOrderConfig.yotpoProductInformationFromMaster && currentProduct.variant) {
currentProduct = currentProduct.getVariationModel().master;
}

Expand Down Expand Up @@ -592,7 +592,7 @@ function prepareOrderData(order, dateTimes) {

yotpoLogger.logMessage(logHeader +
'Date format for the Yotpo data: ' + constants.DATE_FORMAT_FOR_YOTPO_DATA + '\n' +
'Site preference productInformationFromMaster: ' + exportOrderConfig.productInformationFromMaster + '\n' +
'Site preference yotpoProductInformationFromMaster: ' + exportOrderConfig.yotpoProductInformationFromMaster + '\n' +
'Site preference exportGroupIdInOrder: ' + exportOrderConfig.exportGroupIdInOrder + '\n' +
'Order Locale ID: ' + order.customerLocaleID + '\n' +
logFooter, 'debug', logLocation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ function getRatingsOrReviewsData(currentLocale, productId) {
if (isCartridgeEnabled && (yotpoConfig.isReviewsEnabled || yotpoConfig.isRatingsEnabled)) {
var ProductMgr = require('dw/catalog/ProductMgr');
var currentProduct = ProductMgr.getProduct(productId);
var productInformationFromMaster = yotpoConfig.productInformationFromMaster;
var yotpoProductInformationFromMaster = yotpoConfig.yotpoProductInformationFromMaster;

if (currentProduct.variant) {
if (productInformationFromMaster) {
if (yotpoProductInformationFromMaster) {
currentProduct = currentProduct.getVariationModel().master;
}
}
Expand Down