- 001
- 002
- 003
- 004
- 005
- 006
- 007
- 008
- 009
- 010
- 011
- 012
- 013
- 014
- 015
- 016
- 017
- 018
- 019
- 020
- 021
- 022
- 023
- 024
- 025
- 026
- 027
- 028
- 029
- 030
- 031
- 032
- 033
- 034
- 035
- 036
- 037
- 038
- 039
- 040
- 041
- 042
- 043
- 044
- 045
- 046
- 047
- 048
- 049
- 050
- 051
- 052
- 053
- 054
- 055
- 056
- 057
- 058
- 059
- 060
- 061
- 062
- 063
- 064
- 065
- 066
- 067
- 068
- 069
- 070
- 071
- 072
- 073
- 074
- 075
- 076
- 077
- 078
- 079
- 080
- 081
- 082
- 083
- 084
- 085
- 086
- 087
- 088
- 089
- 090
- 091
- 092
- 093
- 094
- 095
- 096
- 097
- 098
- 099
- 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 .= '<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>';
3_dar 18.05.2020 20:17 # 0
3.14159265 18.05.2020 23:23 # 0
KOPOHABuPYC 18.05.2020 23:24 # 0
guest8 18.05.2020 23:37 # −999
3.14159265 18.05.2020 23:41 # 0
2. Оффтоп был оффтопом, и в принципе не нужен.
3. Забавно посмотреть багор Сёмы.
В бесконечном стоке и xyzе остались бекапы всех тредов, так что ничего не проёбано. Скажем спасибо инженерным отделам.
Я лично против таких методов. Но в данном конкретном случае ГК дико лагал.
guest8 18.05.2020 23:43 # −999
guest8 18.05.2020 23:44 # −999
3.14159265 18.05.2020 23:45 # 0
На главной.
Лично я вижу это как оптимизацию БД. На чанах треды тоже уходят в бамп-лимит и их смывает.
guest8 18.05.2020 23:46 # −999
3.14159265 18.05.2020 23:48 # 0
Можно считать ГК бордой, а бесконечный сток и xyz его архивами, типа нямы и метачана.
guest8 18.05.2020 23:52 # −999
3.14159265 18.05.2020 23:56 # 0
Это термины конца нулевых, когда никаких сосачей не было.
guest8 19.05.2020 00:11 # −999
BECEHHuu_nemyx 19.05.2020 00:22 # 0
guest8 19.05.2020 00:24 # −999
guest8 19.05.2020 00:29 # −999
3.14159265 18.05.2020 23:38 # 0
guest8 18.05.2020 23:40 # −999
3.14159265 18.05.2020 23:42 # 0