Ross Ireland
01/13/2020, 7:19 PMPabloZ
01/13/2020, 7:55 PMPabloZ
01/13/2020, 7:55 PMRoss Ireland
01/13/2020, 8:05 PMPabloZ
01/13/2020, 8:08 PMRoss Ireland
01/13/2020, 9:32 PMSteve Goldberg
01/14/2020, 11:10 AMSteve Goldberg
01/14/2020, 11:11 AMPabloZ
01/14/2020, 12:01 PM/* global SC */
define('SZeta.OneResultRedirect', [
'Backbone'
], function SZetaOneResultRedirect(
Backbone
) {
'use strict';
return {
mountToApp: function mountToApp (application) {
application.getLayout().on('beforeAppendView', function onBeforeAppendView() {
var itemsInfo;
var firstItem;
var onlyOneItem;
var plpComponent = application.getComponent('PLP');
if (plpComponent) {
itemsInfo = plpComponent.getItemsInfo();
firstItem = itemsInfo && itemsInfo.length > 0 && itemsInfo[0];
onlyOneItem = itemsInfo && itemsInfo.length === 1;
if (!onlyOneItem || !firstItem) {
return;
}
if (SC.ENVIRONMENT.jsEnvironment === 'browser') {
Backbone.history.navigate(firstItem.keyMapping_url, { trigger: true });
}
}
});
}
};
});
Disclaimer: This hasn't been tested except for the bare minimum. It's not something that is live on any projects either. Use at own discression š_._PabloZ
01/14/2020, 12:09 PMPabloZ
01/14/2020, 12:14 PMPabloZ
01/14/2020, 12:16 PMSteve Goldberg
01/14/2020, 12:20 PM