问题
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