I tried this `var pdp = container.getComponent("PD...
# suitecommerce
s
I tried this
var pdp = container.getComponent("PDP");
if (pdp) {
console.log("pdp", pdp);
var iteminfo = pdp.getItemInfo();
console.log("iteminfo", iteminfo);
}
pdp has obj inside but the iteminfo is null What do I do?
s
If you call this too early, for example in the entry point file, then it will return null because the view hasn’t been rendered yet
s
I tried this:
pdp.on("afterViewRender", function () {
var iteminfo = pdp.getItemInfo();
console.log("iteminfo", iteminfo);
but does not seems to work either
s
And are you using that in a view module or an entry point module
s
entry point
s
Right, as I said, I think it is too early. This method gets the currently selected item’s info - even with that event (that I’m surprised even fires) it’s too early
Call it in the view
s
looks like afterShowContent works if in entry