Each item in my checkout cart have deal_price
. I want to get deal_price
of each item. But it only get deal_price
of first item.
$quote = Mage::getSingleton('checkout/cart')->getQuote();
$discount = 0;
if (Mage::getStoreConfigFlag('dailydeal/configuration/enabled')) {
$resource = Mage::getSingleton('core/resource');
$cartItems = $quote->getAllItems();
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*')
->joinTable($resource->getTableName('dailydeal_deal'), 'product_id = entity_id', array('deal_id' => 'deal_id', 'deal_price' => 'deal_price'), '{{table}}.status=1', 'inner');
foreach ($cartItems as $item) {
$productId = $item->getProductId();
$qty = $item->getQty();
$productPrice = $item->getPrice();
echo $productPrice;
echo "<br/>";
$deal = $collection->addAttributeToFilter('entity_id', $productId)->getFirstItem();
$dealPrice = $deal->getDealPrice();
echo($dealPrice);
echo "<br/>";
$discount = ($productPrice - $dealPrice) * $qty + $discount;
echo($discount);
}