I have this view that gives the quantity on hand for requested products:
<view-entity entity-name="ProductInventoryItemAndFacilitySum"
package-name="org.ofbiz.product.product"
title="View entity joining Product and InventoryItem to allow
queries for InventoryItem based on product attributes">
<member-entity entity-alias="PR" entity-name="Product"/>
<member-entity entity-alias="II" entity-name="InventoryItem"/>
<alias entity-alias="II" name="facilityId" group-by="true"/>
<alias entity-alias="PR" name="productId" group-by="true"/>
<alias entity-alias="PR" name="description" group-by="true"/>
<alias entity-alias="PR" name="brandName" group-by="true"/>
<alias entity-alias="PR" name="productName" group-by="true"/>
<alias entity-alias="PR" name="internalName" group-by="true"/>
<alias entity-alias="PR" name="normallyStocked" group-by="true"/>
<alias entity-alias="PR" name="isCatalogItem" group-by="true"/>
<alias entity-alias="PR" name="productTypeId" group-by="true"/>
<alias entity-alias="II" name="availableToPromiseTotal"
function="sum"/>
<alias entity-alias="II" name="quantityOnHandTotal" function="sum"/>
<view-link entity-alias="PR" rel-entity-alias="II">
<key-map field-name="productId"/>
</view-link>
<relation type="one" fk-name="PROD_INV_SUM_PROD"
rel-entity-name="Product">
<key-map field-name="productId"/>
</relation>
<relation type="many" fk-name="PROD_INV_SUM_PRC"
rel-entity-name="ProductPrice">
<key-map field-name="productId"/>
</relation>
</view-entity>
However, if there is no InventoryItem record for the Product, there are no
results. I would like availableToPromiseTotal to return zero (or null) if
there are no InventoryItems for the Product. I can do this by making two
queries, but it would be nice to get it in one. Is there a way to say that
the InventoryItem is not required in the join?
Skip