actions.class.php 2.26 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php

/**
 * product actions.
 *
 * @package    sf
 * @subpackage product
 * @author     Atma
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class productActions extends sfActions
{
    /**
     * Executes index action
     *
     * @param sfRequest $request A request object
     */
    public function executeIndex(sfWebRequest $request)
    {

    }
    public function executeShow(sfWebRequest $request)
    {
        $product = $this->getRoute()->getObject();
        $this->forward404Unless(!$product->getIsDelete() && $product->getOfferCount() > 0);
        if(!$product->getIsDetail()){
            $cats = $product->getCats();
            if(count($cats) > 0){
                $this->redirect('@catalog_show?alias=' . $cats[0]['alias'] . '&sf_culture=' . $this->getUser()->getCulture());
            }
        }
        $this->forward404Unless($product->getIsDetail());
        $this->culture = $this->getUser()->getCulture();
        $this->basket_id = $this->getUser()->getAttribute('basket_id');

        $this->product = Doctrine_Query::create()
            ->select("p.*, c.*, ct.*, o.*, ppv.*, pp.*, ppl.*, t.*, to.*, tpp.*, bo.*")
            ->from('Product p')
            ->leftJoin('p.Cats c')
            ->leftJoin("c.Translation ct")
            ->leftJoin('p.Offer o WITH o.is_delete = 0')
            ->leftJoin('o.BasketOffer bo WITH bo.basket_id = ?', $this->basket_id)
//            ->leftJoin('(SELECT * FROM Product cp LEFT JOIN Offer co ON co.id = cp.product_id WHERE co.is_delete = 0 ORDER BY co.sort ASC ) o ON o.id = p.product_id')
            ->leftJoin('p.ProductPropValue ppv')
            ->leftJoin('ppv.ProductProp pp')
            ->leftJoin('pp.ProductPropList ppl')
            ->innerJoin('p.Translation t WITH t.lang = \'' . $this->culture . '\'')
            ->leftJoin('o.Translation to WITH to.lang = \'' . $this->culture . '\'')
            ->leftJoin('pp.Translation tpp WITH tpp.lang = \'' . $this->culture . '\'')
            ->leftJoin('ppl.Translation tppl WITH tppl.lang = \'' . $this->culture . '\'')
            ->andWhere('p.id = ?', $product->getId())
            ->andWhere("p.is_delete = 0")
            ->orderBy('o.sort asc')
            ->fetchOne();


        $this->setLayout('layoutPage');

    }
}