intershop get date in .isml template

陌路散爱 提交于 2019-12-11 06:35:30

问题


I need to check the condition:

<isif condition="#not ((Product:QLC_Enable EQ 'true') AND (Product:QLC_ValidTo > NOW) AND (Product:QLC_Quantity < 1))#">                        
    <span class="items-in-stock align-left">
        <isinclude template="product/inc/CC_StockStatus"/>
    </span>
</isif>

But it seems that it is incorrect to use this segment:

Product:QLC_ValidTo > NOW

Particularly the problem is the syntax for 'NOW'. I have no idea how it should be set and cannot find out in their documentation.

Can anybody help?


回答1:


I don't believe that this is possible in isml. Beter to write a ProductBO extension and write the condition in java. You can then call the extension in isml to display the element. Avoid putting too much logic in isml, it should only function as the view.

Example

<isif condition="#NOT ((Product:QLC_Enable EQ 'true') AND (Product:Extension("ProductExt"):isValid) AND (Product:QLC_Quantity < 1))#">                        
    <span class="items-in-stock align-left">
        <isinclude template="product/inc/CC_StockStatus"/>
    </span>
</isif>

You can see here how to create a business object extension.

public interface ProductBOExtension extends BusinessObjectExtension<ProductBO>
{
    public static final String EXTENSION_ID = "ProductExt";
    public boolean isValid();
}

Implementation class

public class ProductBOExtensionImpl extends AbstractBusinessObjectExtension<ProductBO> implements ProductBOExtension
{
    public boolean isValid(){
        return this.getExtendedObject().getAttributeValue("QLC_ValidTo").getDateValue().after(new Date());
    }
}


来源:https://stackoverflow.com/questions/46728270/intershop-get-date-in-isml-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!