<?php
class basketComponents extends sfComponents
{
    public function executeCounter(sfWebRequest $request)
    {
        $this->counter = $this->getUser()->getBasket()->getCount();
        $this->sum = $this->getUser()->getBasket()->getSum();
    }
    public function executeBasket(sfWebRequest $request)
    {
        $user = $this->getUser();
        $basket = $user->getBasket();
        $this->culture = $user->getCulture();
        $this->offers = Doctrine_Query::create()
            ->select("o.*, t.*, b.*, p.id, pt.id, p.product_img, p.alias, p.free_shipping, pt.lang, pt.title")
            ->from("Offer o")
            ->innerJoin("o.Translation t ON (t.id = o.id AND t.lang = '" . $this->culture . "')")
            ->innerJoin("o.BasketOffer b")
            ->innerJoin("o.Product p WITH p.is_delete = 0")
            ->innerJoin("p.Translation pt ON (pt.id = p.id AND pt.lang = '" . $this->culture . "')")
            ->where("b.basket_id = ?", $basket->getId())
            ->andWhere("o.is_delete = 0")
            ->fetchArray();
        if(count($this->offers) > 0){
            $this->info = $user->getBasketInfo();
        }
    }
}