_product.php 1.94 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
<?php
if (isset($product)) {
    $translation = $product['Translation'];
    $productImg = explode(';', $product['product_img']);
    $productImg = (count($productImg) > 0 ? $productImg[0] : false);
    $q = Doctrine::getTable('Product')->findOneById($product['id'])->getOffer();
    $discount_available = false;
    foreach ($q as $offer) {
        if ($offer->getDiscountAvailable() == 1) {
            $discount_available = true;
            break;
        }
    }
        echo '<div class="catalog_category_child_item ' . ($discount_available ? 'discount' : '') . '">';
        if ($discount_available) {
            echo '<div class="discount_available"><div class="discount_available_desc">Ищите наши QR-коды в видео и соц. сетях и забирайте скидку</div><div class="discount_available_title">Доступен со скидкой</div></div>';
        }
        echo '<' . ($product['is_detail'] ? 'a' : 'span') . ' href="' . url_for("@product_show?alias=" . $product['alias']) . '" class="anb">';
        if($productImg){
            echo '<img src="/i/n.gif" style="background-image: url(/u/i/' . Page::replaceImageSize($productImg, 'S') . ');" />';
        }else
        {
            $offerImg = '';
            foreach ($q as $offer) {
                if (strlen($offer->getImg()) > 3)
                $offerImg = $offer->getImg();
                break;
            }
            if (strlen($offerImg) > 3 )
            {
                echo '<img src="/i/n.gif" style="background-image: url(/u/i/' . $offerImg . '); background-size: cover" />';
            }else
            {
                echo '<img src="/i/n.gif" style="background-image: url(/i/no_photo.png);" />';
            }

        }
        echo '<span class="green_link">' . $translation[$sf_user->getCulture()]['title'] . '</span>';
        echo '</' . ($product['is_detail'] ? 'a' : 'span') . '>';
        echo '<i class="br20"></i>';
        echo '</div>';
}
?>