Update Features in the PDP page for matrix items

Features should be changed based on child matrix item when we selecting item options, if there are no features in the child item record, then features will show from parent item. 

in view file

{
    'use strict';

	// @class jj.Feature.Feature.View @extends Backbone.View
	return Backbone.View.extend({

		template: jj_feature_feature_tpl

	,	initialize: function (options) {
		var self = this;
		this.options = options
		this.pdp = this.options.container.getComponent('PDP');
		console.log('pdp',this.pdp );
		var parentFeature = this.pdp.getItemInfo().item.storedetaileddescription;
		console.log('featureparent', this.pdp.getItemInfo().item.storedetaileddescription);
		this.pdp.on('afterOptionSelection', function () {
			// Get the selected matrix child(s)
			var selectedMatrixChilds = self.pdp.getSelectedMatrixChilds()[0];
			console.log(' selectedMatrixChilds ', selectedMatrixChilds);
			console.log('current featur', selectedMatrixChilds.custitem_jj_specification_data)
			self.feature = self.pdp.getSelectedMatrixChilds()[0].custitem_jj_specification_data
			if (!self.feature) {
				self.feature = parentFeature;
			}

			self.render();

		});

		}
		//@method getContext @return jj.Feature.Feature.View.Context
		,getContext: function getContext() {
            console.log('getcontext this', this)
            var url = window.location.href;
            console.log('url', url)
            if (url.indexOf("?") != -1 && url.indexOf("=") != -1) {
                console.log('has content');

                this.childinfo = this.pdp.getSelectedMatrixChilds()[0];
                console.log('childinfo', this.childinfo);
                var childfeatuteContent = this.childinfo.custitem_jj_specification_data
                console.log('childfeatuteContent', childfeatuteContent);

                var feature = childfeatuteContent;
                if (!childfeatuteContent) {
                    feature = this.pdp.getItemInfo().item.storedetaileddescription;
                }

                console.log('feature if', feature);

            }
            else {
                feature = this.pdp.getItemInfo().item.storedetaileddescription;

                console.log('featureelse', feature);

            }
            return {
                ItemDescription: feature
            };
        }
	});
});

Leave a comment

Your email address will not be published. Required fields are marked *