for the PDP component is there a method to know if...
# suitecommerce
t
for the PDP component is there a method to know if the PDP view is the quickview or the full view? currently we are inferring by page elements but is there is something in the extensibility API that is a better approach
s
Not really. You can get the class names for the different views. Typically in this scenario I would recommend comparing the current view instance’s prototype against each class
Copy code
// Add Product Details Full View and Quick View as dependencies

initialize: function () {
    var container = this.options.container;
    this.parentView = container.getLayout().getCurrentView();
    this.isFullView = this.parentView instanceof ProductDetailsFullView;
}
t
that helps
I see a viewToBeRendered property as well
will try both
instanceof doesn't seem to work in beforeShowContent
so I will try the other method
pdp.on("beforeShowContent", function () { if (plp) { console.log('PA beforeShowContent') console.log('PA beforeShowContent',pdp.viewToBeRendered.$el[0]) var parentView = container.getLayout().getCurrentView(); var isFullView = parentView instanceof ProductDetailsFullView; var isQuickView = parentView instanceof ProductDetailsQuickView;
this worked
var viewId = pdp.viewToBeRendered.$el.attr("id"); var isFullView = viewId==='ProductDetails.Full.View'; var isQuickView = viewId==='ProductDetails.QuickView.View';
s
OK
A very minor improvement would be to use the strings we attach to the PDP component rather than hard coding them
eg
pdp.PDP_FULL_VIEW
But otherwise, glad it works. And yeah it probably won’t work in
beforeShowContent
because … it’s not been rendered yet
In my mind, you would either use
initialize()
or overwrite the view’s
render()
, checking things there to see if it should be intialised/rendered