Alright,

this is driving me insane, and after searching all through the available
ofbiz screens and beanshell files, I would really appreciate some help on
this. 

All I want to do is to retrieve a sample of four products (randomly
selected) that contains the description, title, price, listprice, productId
and brandName, so that I can access the information via ftl later on and
display 4 productboxes...

I got the first part together just fine: 

/*Find Products*/
delegator = request.getAttribute("delegator");
products = delegator.findAll("Product");
productShowLimit=4;




//now slim it down to promoShowLimit
productArrayList = new ArrayList(products);

productPromos = null;
if (productArrayList.size() > productShowLimit) {
    productPromos = new ArrayList(productShowLimit);
    for (i = 0; i < productShowLimit; i++) {
        
            randomIndex = Math.round(java.lang.Math.random() *
(productArrayList.size() - 1));
        
        

        productPromos.add(productArrayList.get((int) randomIndex));
    }

} else {
    productPromos = productArray;
}


But I cannot get my head around on how to link this information to the
listPrice... getRelatedOne on ProductPrice retrieves all the prices for a
certain product: 

productPrices = null;
Iterator p = productPromos.iterator();
while(p.hasNext()){
 GenericValue p = (GenericValue) p.next();
 prices = p.getRelated("ProductPrice");
 System.out.println("Out: "+  prices);   
}


But i cannot combine that information with the previous resultMap
(productPromos )...  Also, I've read on 

http://www.opensourcestrategies.com/ofbiz/ofbiz_entity_cookbook.txt

that you shouldn't access the product data table directly (which makes
sense), and so I can't help but wonder on whether there are easier/already
existing ways of what I am trying to accomplish...
-- 
View this message in context: 
http://www.nabble.com/Cannot-Retrive-price-from-ProductPrice-tp10407489p20832124.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Reply via email to