components.class.php 1.34 KB
Newer Older
Яков's avatar
first  
Яков committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?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();
        }
Яков's avatar
test    
Яков committed
27
28
29
        if ($this->getUser()->hasAttribute('active_discount') && $this->getUser()->getAttribute('active_discount') != false) {
            $this->percent = $this->getUser()->getAttribute('active_discount');
        }
Яков's avatar
first  
Яков committed
30
31
    }
}