echo Yii::app()->createUrl('product/view', UtilityHelper::productLink($product->id));
                ?>
"><span class="sale round">SALE</span></a>	
		</div>
		<?php 
                $tpath = Yii::app()->request->baseUrl . '/img/no-image.jpg';
                if (!empty($product->thumbs)) {
                    $tpath = Yii::app()->request->baseUrl . $product->thumbs[0]->source;
                }
                ?>
				<?php 
                echo CHtml::image($tpath, '', array('class' => 'product_img'));
                ?>
		<div style="background-color:#e4f3f2;">
			<a href="<?php 
                echo Yii::app()->createUrl('product/view', UtilityHelper::productLink($product->id));
                ?>
"><span class="product_name"><?php 
                echo $product->getName();
                ?>
</span>
			<span class="product_price"><?php 
                echo UtilityHelper::formatPrice($product->price);
                ?>
</span></a>					
		</div>						
	</div>
	<?php 
            }
        }
    }
 public function actionAddToCart($id)
 {
     //Yii::app()->user->setState('user_cart', NULL);
     if (isset($id) && isset($_REQUEST['quantity']) && is_numeric($id) && is_numeric($_REQUEST['quantity']) && $id * $_REQUEST['quantity'] > 0) {
         $cart = $this->getCart();
         $product = Product::model()->findByPk($id);
         if (!empty($product)) {
             $match = false;
             $ops = $product->productOptions;
             $price = $product->price;
             $order = array('product_id' => $id, 'name' => $product->getName(), 'model' => $product->model, 'quantity' => intval($_REQUEST['quantity']), 'stock' => $product->quantity, 'price' => $price, 'total' => intval($_REQUEST['quantity']) * $price);
             if (!empty($ops)) {
                 if (isset($_REQUEST['quick'])) {
                     $this->redirect(array_merge(array('/product/view'), UtilityHelper::productLink($id)));
                 }
                 //$this->redirect('product/view', array('category'=>$_GET['category'],'subcategory'=>$_GET['subcategory'],'product'=>$product->getLink()));
                 $stock = 0;
                 if ($this->addProductOption($product->id, intval($_REQUEST['quantity']), $price, $stock)) {
                 } else {
                     Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_ERROR, 'Please fill out all required options');
                     $this->redirect(Yii::app()->request->urlReferrer);
                 }
                 $order['price'] = $price;
                 $order['stock'] = $stock;
                 $order['total'] = $order['quantity'] * $order['price'];
                 $order['option'] = $this->_orderoption;
             }
             if ($order['stock'] >= $order['quantity']) {
                 if (empty($cart)) {
                     $cart['items'] = array($order);
                 } else {
                     foreach ($cart['items'] as $i => $porder) {
                         if (!empty($porder['option']) && !empty($order['option'])) {
                             if ($this->orderCompare($order['option'], $porder['option'])) {
                                 if (isset($_REQUEST['cart'])) {
                                     $cart['items'][$i]['quantity'] = $order['quantity'];
                                     $cart['items'][$i]['total'] = $order['total'];
                                 } else {
                                     $cart['items'][$i]['quantity'] += $order['quantity'];
                                     $cart['items'][$i]['total'] += $order['total'];
                                 }
                                 $match = true;
                                 break;
                             }
                         } elseif ($porder['product_id'] == $order['product_id']) {
                             if (isset($_REQUEST['cart'])) {
                                 $cart['items'][$i]['quantity'] = $order['quantity'];
                                 $cart['items'][$i]['total'] = $order['total'];
                             } else {
                                 $cart['items'][$i]['quantity'] += $order['quantity'];
                                 $cart['items'][$i]['total'] += $order['total'];
                             }
                             $match = true;
                             break;
                         }
                     }
                     if (!$match) {
                         $cart['items'][] = $order;
                     }
                 }
             } else {
                 Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_ERROR, 'The quantity you chose exceeds the quantity in stock.');
             }
             /*Yii::log( "OrderCreateActionvaliid: ".CVarDumper::dumpAsString( $cart),
             			CLogger::LEVEL_ERROR, "order.actions.create" 
             		);*/
             Yii::app()->user->setState('user_cart', $cart);
             if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                 $this->renderPartial('_cart', array('cart' => $cart['items']), false, true);
                 Yii::app()->end();
             }
             $this->render('cart', array('cart' => $cart['items']));
         }
     }
 }