- 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
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
$output = '<div class="catalog catalog-category">';
$query = db_select('taxonomy_term_data','td');
$query->innerJoin('field_data_field_category', 'fc', "fc.field_category_tid = td.tid");
$query->innerJoin('taxonomy_term_hierarchy', 'tth', "tth.tid = td.tid");
$query->innerJoin('node', 'n', "n.nid = fc.entity_id");
$query->condition('td.vid', 4);
$query->condition('n.status', 1);
$query->condition('tth.parent', 0);
$query->fields('td', array('tid', 'name'));
$query->groupBy('td.tid');
$query->orderBy('td.weight', 'ASC');
$terms = $query->execute()->fetchAll();
foreach ($terms as $term) {
$prod_out = '';
$query = db_select('field_data_field_product', 'fp');
// Выбираем товары текущего типа
$query->innerJoin('node', 'n', "n.nid = fp.entity_id");
$query->innerJoin('field_data_field_category', 'fc', "fc.entity_id = n.nid");
$query->condition('n.status', 1);
$query->condition('fc.field_category_tid', $term->tid);
// Заголовок товара
$query->innerJoin('commerce_product', 'cp', "cp.product_id = fp.field_product_product_id");
$query->condition('cp.status', 1);
$query->fields('cp', array('title'));
// Цена без скидки
$query->innerJoin('field_data_commerce_price', 'dcp', "dcp.entity_id = fp.field_product_product_id");
$query->fields('dcp', array('commerce_price_amount'));
// Размер скидки
$query->leftJoin('field_data_field_discount', 'dcpd', "dcpd.entity_id = fp.field_product_product_id");
$query->fields('dcpd', array('field_discount_value'));
// Цена со скидкой
$query->leftJoin('field_data_field_price_new', 'dcpn', "dcpn.entity_id = fp.field_product_product_id");
$query->fields('dcpn', array('field_price_new_value'));
// Первое изображение
$query->innerJoin('field_data_field_image', 'dfi', "dfi.entity_id = fp.field_product_product_id");
$query->condition('dfi.delta', 0);
$query->fields('dfi', array('field_image_fid'));
$query->innerJoin('field_data_field_weight', 'fw', "fw.entity_id = fp.field_product_product_id");
$query->addExpression("(SELECT GROUP_CONCAT(td.name SEPARATOR ', ') FROM field_data_field_season AS dfs INNER JOIN taxonomy_term_data AS td ON td.tid=dfs.field_season_tid WHERE dfs.entity_id=n.nid)","name");
// Маркер
$query->leftJoin('field_data_field_marker', 'dfm', "dfm.entity_id = fp.field_product_product_id");
$query->fields('dfm', array('field_marker_value'));
// Товар
$query->fields('fp', array('field_product_product_id'));
// Связанная с товаром нода
$query->fields('n', array('nid'));
$query->range(0, 4);
$query->orderBy('fw.field_weight_value', 'ASC');
$products = $query->execute()->fetchAll();
// $output .= '<h2>' . l($term->name, 'taxonomy/term/'.$term->tid) . '</h2>';
$output .= '<div class="product_items">';
$output .= '<div class="catalog_item"><div style="width: 225px; height: 340px;"><h2>' . l($term->name, 'taxonomy/term/'.$term->tid) . '</h2></div></div>';
foreach ($products as $product) {
$fid = $product->field_image_fid;
if ($fid != 0 && is_numeric($fid)) {
$file_picture = file_load($fid);
$imageUrl = image_style_url('catalog', $file_picture->uri);
$title = $product->title;
$photo = "<img class='lazy-image' data-src='{$imageUrl}' alt='{$title}' title='{$title}'>";
}
else $photo = '';
$prod_out .= '<div class="catalog_item">';
$prod_out .= '<div class="title">' . l($product->title . '<br><span>' . $product->name . '</span><div>XS S M L XL</div>', 'node/'.$product->nid, array('html' => TRUE, 'query' => array('id' => $product->field_product_product_id))).'</div>';
$prod_out .= '<div class="image">' . $photo . '</div>';
if (!empty($product->field_discount_value)) {
$prod_out .= '<div class="views-field-field-discount"><div class="field-content">Sale ' . $product->field_discount_value . ' %</div></div>';
}
if (!empty($product->field_marker_value)) {
$prod_out .= '<div class="views-field-field-marker"><div class="field-content field-content field-content-' . $product->field_marker_value . '">' . ($product->field_marker_value == 'new'?'Новинка':'Бестселлер') . '</div></div>';
}
if (!empty($product->field_price_new_value)) {
$price = '<s>' . number_format($product->commerce_price_amount/100,0,'',' ') . '</s> ' . number_format($product->field_price_new_value,0,'',' ') . ' Р';
}
else {
$price = number_format($product->commerce_price_amount/100,0,'',' ') . ' Р';
}
$prod_out .= '<div class="views-field-field-price-new">' . $price . '</div>';
$prod_out .= '</div>';
}
}
$output .= $prod_out;
$output .= '<div class="catalog_item" style="position: absolute;">' . l('<img src="/sites/all/themes/base/img/strelka.png" style="width: 10px; height: 17px;">', 'taxonomy/term/'.$term->tid, array('html' => true)) . '</div>';
$output .= '</div>';
2. Оффтоп был оффтопом, и в принципе не нужен.
3. Забавно посмотреть багор Сёмы.
В бесконечном стоке и xyzе остались бекапы всех тредов, так что ничего не проёбано. Скажем спасибо инженерным отделам.
Я лично против таких методов. Но в данном конкретном случае ГК дико лагал.
На главной.
Лично я вижу это как оптимизацию БД. На чанах треды тоже уходят в бамп-лимит и их смывает.
Можно считать ГК бордой, а бесконечный сток и xyz его архивами, типа нямы и метачана.
Это термины конца нулевых, когда никаких сосачей не было.