简体   繁体   中英

InterShop dates comparison condition doesn't work

I have a condition which doesn't work:

<isif condition="#(Product:QLC_ValidTo > current_date)#">                        
    <span class="items-in-stock align-left">
        <isinclude template="product/inc/CC_StockStatus"/>
    </span>
</isif>

There are two valid values for both operands:

Product:QLC_ValidTo = 29.11.16 and current_date = 13.10.17

but it doesn't work.

I suppose is it incorrect to try to implement it as a simple comparison and values should be converted to another format?

I don't agree with the following approach, see my previous post. If you insist on only isml then you can do the following.

<%
    getPipelineDictionary().put("current_date",new Date());
%>
<isif condition="#(Product:QLC_ValidTo:getTime > current_date:getTime)#">                        
    <span class="items-in-stock align-left">
        <isinclude template="product/inc/CC_StockStatus"/>
    </span>
</isif>

Retrieve the milliseconds as a long and comparing it with gt operator. These operator only work with numbers.

Like it said before, rather do this in an extension. You can unit test it, deal with timezone issues, readability would improve etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM