• Как сделать на Opencart вывод товаров с категориями на главную страницу?

    @Skofild2016 Автор вопроса
    Изучаю Frontend
    вечер добрый циклы сделал в контролере но отображает только последнюю категорию с товаром почему так
    сам код вот

    <?php
    class ControllerCommonHome extends Controller {
    public function index() {
    $this->load->language('product/category');

    $this->load->model('catalog/category');

    $this->load->model('catalog/product');

    $this->load->model('tool/image');

    $arr_category = $this->model_catalog_category->getCategories(0);

    foreach($arr_category as $id){
    $category_id = $id['category_id'];
    $category_info = $this->model_catalog_category->getCategory($category_id);

    print_r($category_info);

    $this->document->setTitle($category_info['meta_title']);
    $this->document->setDescription($category_info['meta_description']);
    $this->document->setKeywords($category_info['meta_keyword']);

    $data['categories'] = array();

    $data['heading_title'] = $category_info['name'];

    $data['products'] = array();

    $filter_data = array(
    'filter_category_id' => $category_id,
    );

    $product_total = $this->model_catalog_product->getTotalProducts($filter_data);

    $results = $this->model_catalog_product->getProducts($filter_data);

    foreach ($results as $result) {
    if ($result['image']) {
    $image = $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
    } else {
    $image = $this->model_tool_image->resize('placeholder.png', $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
    }

    if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
    $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
    } else {
    $price = false;
    }

    $data['products'][] = array(
    'product_id' => $result['product_id'],
    'thumb' => $image,
    'name' => $result['name'],
    'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
    'price' => $price,
    'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
    // 'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
    );
    };

    $data['continue'] = $this->url->link('common/home');

    $data['column_left'] = $this->load->controller('common/column_left');
    $data['column_right'] = $this->load->controller('common/column_right');
    $data['content_top'] = $this->load->controller('common/content_top');
    $data['content_bottom'] = $this->load->controller('common/content_bottom');
    $data['footer'] = $this->load->controller('common/footer');
    $data['header'] = $this->load->controller('common/header');

    $this->response->setOutput($this->load->view('product/category', $data));
    }
    }
    } ?>
    Ответ написан
  • Как сделать заказ с одного склада?

    @Skofild2016 Автор вопроса
    Изучаю Frontend
    Нет специалистов по Битриксу?
    Ответ написан
    Комментировать
  • Какой самый быстрый метод по поиску в DOM?

    @Skofild2016
    Изучаю Frontend
    Вроде быстрее всего из DOM id вытаскивать. По мне дак это самый быстрый способ.
    Ответ написан
    Комментировать
  • Как настроить снипетты в vsCode?

    @Skofild2016
    Изучаю Frontend
    Чтобы сделать сниппет, зайди в файл-настройки-новый сниппет.
    Сохранить файл. Откроется файл сниппета, там есть пример закоменитрованный.
    Все подробно описано. Имя сниппета, коротное имя по которому будет вызываться, в каких файлах будет работать, тело сниппета и описание.

    У вас такой сниппет будет.
    "@media500": {
    "prefix": "@mw500",
    "scope": "css",
    "body": [
    "@media (max-width: 500px){$1}",
    ],
    "description": "Подключение @media"
    },
    Знак $ это где будет установлен курсор после разворота сниппета.
    Ответ написан