Search code examples
intershop

ISML isDefined() returns false altough object contains value in field


I am creating a ISML module to which I am passing a ProductBO instance. In the mentioned module I try to get OutgoingProductLinks field which I see it is filled with correct values which I defined in BackOffice but when isDefined() is called on that field, it returns false and when I try to use that field in <isloop> tag it logs error message that says:

Loop iterator identifier '#ProductBO:ExtensibleObject:OutgoingProductLinks#' does not specify a valid Iterator.

The specific project I am working on is based on app_sf_responsive sample and therefore it uses it's ViewProduct pipeline(it is not overriden in other cartridges) which returns ProductBO object that is used in several other places and fields that are used there are normally available for use in ISML.

The following code snippet always returns false:

<isif condition="#isDefined(ProductBO:ExtensibleObject:OutgoingProductLinks)#" >
   <h1>Outgoing product links are defined</h1>
<iselse>
   <h1 style="color: red;">Outgoing product links are NOT defined </h1>
</isif>

And this is where I try to actually use mentioned field:

<isloop iterator="#ProductBO:ExtensibleObject:OutgoingProductLinks#" alias="ProductLink">
//Code that uses linked products
</isloop>

Do note that both isDefined() checks for ProductBO and ExtensibleObject are working, the problem only arises with OutgoingProductLinks

EDIT: Here is the screenshot from debugger showing product links

Debugger showing valid product link values


Solution

  • To add to Johannes answer. If you look at the demo shop code here is how they do it:

    //get the productlink extension from the productBO
    <isset name="ProductBOProductLinksExtension" value="#ProductBO:Extension("ProductLinks")#" scope="request">
    //Link type provider : example cross/up sell, replacement 
    <isset name="LinkTypeProvider" value="#ProductBOProductLinksExtension:LinkTypeProvider#" scope="request">
    //get the link by id from provider See ProductLinkConstants
    <isset name="LinkType" value="#LinkTypeProvider:LinkTypeByID(PageletConfigurationParameters:ProductLinkType:Name)#" scope="request">
    //get a collection of linked productbos
    <isset name="ProductBOs" value="#ProductBOProductLinksExtension:AccessibleOutgoingLinksLinkedObjects(LinkType)#" scope="request">
    

    The advantage is that it only gets the online products.