<?php
use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Extension\SandboxExtension;
use Twig\Markup;
use Twig\Sandbox\SecurityError;
use Twig\Sandbox\SecurityNotAllowedTagError;
use Twig\Sandbox\SecurityNotAllowedFilterError;
use Twig\Sandbox\SecurityNotAllowedFunctionError;
use Twig\Source;
use Twig\Template;
/* Product/list.twig */
class __TwigTemplate_bef9dab78eb246ff81cb0084ef5ae32d4ccdad3d7561b2fda6b324d40f8004e5 extends \Eccube\Twig\Template
{
private $source;
private $macros = [];
public function __construct(Environment $env)
{
parent::__construct($env);
$this->source = $this->getSourceContext();
$this->blocks = [
'stylesheet' => [$this, 'block_stylesheet'],
'javascript' => [$this, 'block_javascript'],
'main' => [$this, 'block_main'],
];
}
protected function doGetParent(array $context)
{
// line 11
return "default_frame.twig";
}
protected function doDisplay(array $context, array $blocks = [])
{
$macros = $this->macros;
$__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e = $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
$__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->enter($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template", "Product/list.twig"));
$__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02 = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
$__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->enter($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template", "Product/list.twig"));
// line 13
$context["body_class"] = "product_page";
// line 11
$this->parent = $this->loadTemplate("default_frame.twig", "Product/list.twig", 11);
$this->parent->display($context, array_merge($this->blocks, $blocks));
$__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->leave($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof);
$__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->leave($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof);
}
// line 16
public function block_stylesheet($context, array $blocks = [])
{
$macros = $this->macros;
$__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e = $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
$__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->enter($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "stylesheet"));
$__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02 = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
$__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->enter($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "stylesheet"));
// line 17
echo " <link rel=\"stylesheet\" href=\"";
echo twig_escape_filter($this->env, $this->extensions['Symfony\Bridge\Twig\Extension\AssetExtension']->getAssetUrl("assets/css/product-list.css"), "html", null, true);
echo "\">
";
$__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->leave($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof);
$__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->leave($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof);
}
// line 20
public function block_javascript($context, array $blocks = [])
{
$macros = $this->macros;
$__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e = $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
$__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->enter($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "javascript"));
$__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02 = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
$__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->enter($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "javascript"));
// line 21
echo "<script>
(function() {
// Lấy URL hiện tại và tạo URLSearchParams
function getCurrentUrlParams() {
const urlParams = new URLSearchParams(window.location.search);
return urlParams;
}
// Cập nhật URL với category filters và reload
function updateCategoryFilters() {
const checkboxes = document.querySelectorAll('.filter-option__checkbox');
const urlParams = getCurrentUrlParams();
// Xóa tất cả category_filter[] cũ (có thể có nhiều giá trị)
const keysToDelete = [];
urlParams.forEach(function(value, key) {
if (key === 'category_filter[]' || key.startsWith('category_filter')) {
keysToDelete.push(key);
}
});
keysToDelete.forEach(function(key) {
urlParams.delete(key);
});
// Thu thập các category IDs đã được chọn
const selectedCategoryIds = [];
checkboxes.forEach(function(checkbox) {
if (checkbox.checked) {
selectedCategoryIds.push(checkbox.value);
}
});
// Chỉ thêm category_filter[] nếu có ít nhất một checkbox được chọn
if (selectedCategoryIds.length > 0) {
selectedCategoryIds.forEach(function(categoryId) {
urlParams.append('category_filter[]', categoryId);
});
}
// Reset về trang 1 khi filter
urlParams.set('pageno', '1');
// Tạo URL mới
const queryString = urlParams.toString();
const newUrl = queryString
? window.location.pathname + '?' + queryString
: window.location.pathname;
// Reload page với query params mới
window.location.href = newUrl;
}
// Khôi phục trạng thái checkbox từ URL và xử lý nút search
document.addEventListener('DOMContentLoaded', function() {
const checkboxes = document.querySelectorAll('.filter-option__checkbox');
const searchButton = document.querySelector('.btn-search');
// Khôi phục trạng thái checkbox từ URL
const urlParams = getCurrentUrlParams();
const selectedCategories = urlParams.getAll('category_filter[]');
checkboxes.forEach(function(checkbox) {
// Set checked nếu category ID có trong URL
if (selectedCategories.includes(checkbox.value)) {
checkbox.checked = true;
}
// Không lắng nghe sự kiện change trên checkbox nữa
});
// Lắng nghe sự kiện click trên nút search
if (searchButton) {
searchButton.addEventListener('click', function() {
updateCategoryFilters();
});
}
});
})();
</script>
";
$__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->leave($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof);
$__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->leave($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof);
}
// line 101
public function block_main($context, array $blocks = [])
{
$macros = $this->macros;
$__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e = $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
$__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->enter($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "main"));
$__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02 = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
$__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->enter($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "main"));
// line 102
echo "
<body>
<!-- breadcrumb section -->
<div class=\"breadcrumb-section\">
<div class=\"container-1360 border-box px-40\">
<nav class=\"breadcrumb\">
<a href=\"#\" class=\"breadcrumb__item text-black\">ホーム</a>
<img src=\"";
// line 109
echo twig_escape_filter($this->env, $this->extensions['Symfony\Bridge\Twig\Extension\AssetExtension']->getAssetUrl("assets/img/default/icons/icon-breadcrumb-arrow.svg"), "html", null, true);
echo "\" alt=\">\" class=\"breadcrumb__separator\">
<a href=\"#\" class=\"breadcrumb__item text-black\">商品一覧</a>
</nav>
</div>
</div>
<!-- product list section -->
<div class=\"container-1200\">
<div class=\"product-list-wrapper\">
<div class=\"product-list-left\">
";
// line 119
if ((array_key_exists("searchable_categories", $context) && (twig_length_filter($this->env, (isset($context["searchable_categories"]) || array_key_exists("searchable_categories", $context) ? $context["searchable_categories"] : (function () { throw new RuntimeError('Variable "searchable_categories" does not exist.', 119, $this->source); })())) > 0))) {
// line 120
echo " ";
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable((isset($context["searchable_categories"]) || array_key_exists("searchable_categories", $context) ? $context["searchable_categories"] : (function () { throw new RuntimeError('Variable "searchable_categories" does not exist.', 120, $this->source); })()));
foreach ($context['_seq'] as $context["_key"] => $context["group"]) {
// line 121
echo " <div class=\"filter-group\">
<div class=\"filter-group__header\">";
// line 122
echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, $context["group"], "parent", [], "any", false, false, false, 122), "name", [], "any", false, false, false, 122), "html", null, true);
echo "</div>
<div class=\"filter-group__options\">
";
// line 124
if ((twig_length_filter($this->env, twig_get_attribute($this->env, $this->source, $context["group"], "children", [], "any", false, false, false, 124)) > 0)) {
// line 125
echo " ";
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable(twig_get_attribute($this->env, $this->source, $context["group"], "children", [], "any", false, false, false, 125));
foreach ($context['_seq'] as $context["_key"] => $context["child"]) {
// line 126
echo " <label class=\"filter-option\">
<input type=\"checkbox\"
class=\"filter-option__checkbox\"
name=\"category_filter[]\"
value=\"";
// line 130
echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, $context["child"], "id", [], "any", false, false, false, 130), "html", null, true);
echo "\"
data-category-id=\"";
// line 131
echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, $context["child"], "id", [], "any", false, false, false, 131), "html", null, true);
echo "\">
<span class=\"filter-option__label\">";
// line 132
echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, $context["child"], "name", [], "any", false, false, false, 132), "html", null, true);
echo "</span>
</label>
";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['child'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 135
echo " ";
} else {
// line 136
echo " ";
// line 137
echo " <label class=\"filter-option\">
<input type=\"checkbox\"
class=\"filter-option__checkbox\"
name=\"category_filter[]\"
value=\"";
// line 141
echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, $context["group"], "parent", [], "any", false, false, false, 141), "id", [], "any", false, false, false, 141), "html", null, true);
echo "\"
data-category-id=\"";
// line 142
echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, $context["group"], "parent", [], "any", false, false, false, 142), "id", [], "any", false, false, false, 142), "html", null, true);
echo "\">
<span class=\"filter-option__label\">";
// line 143
echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, $context["group"], "parent", [], "any", false, false, false, 143), "name", [], "any", false, false, false, 143), "html", null, true);
echo "</span>
</label>
";
}
// line 146
echo " </div>
</div>
";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['group'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 149
echo " ";
}
// line 150
echo " <button class=\"btn-primary btn-search w-100\">
<span>検索する</span>
<svg class=\"btn-search-icon\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">
<rect width=\"24\" height=\"24\" rx=\"12\" fill=\"black\"/>
<path d=\"M16.252 12.001L16.249 12.0039L16.252 12.0068L11.7266 16.5312L10.5957 15.4004L13.1943 12.8027H7.72852V11.2031H13.1924L10.5957 8.60742L11.7266 7.47656L16.252 12.001Z\" fill=\"#FBE800\"/>
</svg>
</button>
</div>
<!-- bottom line -->
<div class=\"bottom-line container-mobile\"></div>
<!-- Product List Right -->
<div class=\"product-list-right\">
<div class=\"product-grid\" id=\"product-grid\">
";
// line 163
if ((twig_get_attribute($this->env, $this->source, (isset($context["pagination"]) || array_key_exists("pagination", $context) ? $context["pagination"] : (function () { throw new RuntimeError('Variable "pagination" does not exist.', 163, $this->source); })()), "totalItemCount", [], "any", false, false, false, 163) > 0)) {
// line 164
echo " ";
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable((isset($context["pagination"]) || array_key_exists("pagination", $context) ? $context["pagination"] : (function () { throw new RuntimeError('Variable "pagination" does not exist.', 164, $this->source); })()));
$context['loop'] = [
'parent' => $context['_parent'],
'index0' => 0,
'index' => 1,
'first' => true,
];
if (is_array($context['_seq']) || (is_object($context['_seq']) && $context['_seq'] instanceof \Countable)) {
$length = count($context['_seq']);
$context['loop']['revindex0'] = $length - 1;
$context['loop']['revindex'] = $length;
$context['loop']['length'] = $length;
$context['loop']['last'] = 1 === $length;
}
foreach ($context['_seq'] as $context["_key"] => $context["Product"]) {
// line 165
echo " <div class=\"product-item\">
<a href=\"";
// line 166
echo twig_escape_filter($this->env, $this->extensions['Symfony\Bridge\Twig\Extension\RoutingExtension']->getUrl("product_detail", ["id" => twig_get_attribute($this->env, $this->source, $context["Product"], "id", [], "any", false, false, false, 166)]), "html", null, true);
echo "\" class=\"product-card-small\">
<div class=\"product-card-small__image\">
<img src=\"";
// line 168
echo twig_escape_filter($this->env, $this->extensions['Symfony\Bridge\Twig\Extension\AssetExtension']->getAssetUrl($this->extensions['Eccube\Twig\Extension\EccubeExtension']->getNoImageProduct(twig_get_attribute($this->env, $this->source, $context["Product"], "main_list_image", [], "any", false, false, false, 168)), "save_image"), "html", null, true);
echo "\" alt=\"";
echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, $context["Product"], "name", [], "any", false, false, false, 168), "html", null, true);
echo "\" ";
if ((twig_get_attribute($this->env, $this->source, $context["loop"], "index", [], "any", false, false, false, 168) > 5)) {
echo " loading=\"lazy\"";
}
echo ">
<div class=\"product-card-small__arrow\">
<img src=\"";
// line 170
echo twig_escape_filter($this->env, $this->extensions['Symfony\Bridge\Twig\Extension\AssetExtension']->getAssetUrl("assets/img/default/icons/icon-heart.svg"), "html", null, true);
echo "\" alt=\"Favorite\" loading=\"lazy\">
</div>
</div>
</a>
<div class=\"product-item__info\">
<a href=\"";
// line 175
echo twig_escape_filter($this->env, $this->extensions['Symfony\Bridge\Twig\Extension\RoutingExtension']->getUrl("product_detail", ["id" => twig_get_attribute($this->env, $this->source, $context["Product"], "id", [], "any", false, false, false, 175)]), "html", null, true);
echo "\">
<h4 class=\"product-item__title\">";
// line 176
echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, $context["Product"], "name", [], "any", false, false, false, 176), "html", null, true);
echo "</h4>
</a>
<div class=\"product-item__price\">
<span class=\"price-symbol\">¥</span>
<span class=\"price-amount\">
";
// line 181
if (twig_get_attribute($this->env, $this->source, $context["Product"], "hasProductClass", [], "any", false, false, false, 181)) {
// line 182
echo " ";
if ((twig_get_attribute($this->env, $this->source, $context["Product"], "getPrice02Min", [], "any", false, false, false, 182) == twig_get_attribute($this->env, $this->source, $context["Product"], "getPrice02Max", [], "any", false, false, false, 182))) {
// line 183
echo " ";
echo twig_escape_filter($this->env, $this->extensions['Eccube\Twig\Extension\EccubeExtension']->getPriceFilter(twig_get_attribute($this->env, $this->source, $context["Product"], "getPrice02IncTaxMin", [], "any", false, false, false, 183)), "html", null, true);
echo "
";
} else {
// line 185
echo " ";
echo twig_escape_filter($this->env, $this->extensions['Eccube\Twig\Extension\EccubeExtension']->getPriceFilter(twig_get_attribute($this->env, $this->source, $context["Product"], "getPrice02IncTaxMin", [], "any", false, false, false, 185)), "html", null, true);
echo " ~ ";
echo twig_escape_filter($this->env, $this->extensions['Eccube\Twig\Extension\EccubeExtension']->getPriceFilter(twig_get_attribute($this->env, $this->source, $context["Product"], "getPrice02IncTaxMax", [], "any", false, false, false, 185)), "html", null, true);
echo "
";
}
// line 187
echo " ";
} else {
// line 188
echo " ";
echo twig_escape_filter($this->env, $this->extensions['Eccube\Twig\Extension\EccubeExtension']->getPriceFilter(twig_get_attribute($this->env, $this->source, $context["Product"], "getPrice02IncTaxMin", [], "any", false, false, false, 188)), "html", null, true);
echo "
";
}
// line 190
echo " </span>
<span class=\"price-tax\">(税込)</span>
</div>
</div>
</div>
";
++$context['loop']['index0'];
++$context['loop']['index'];
$context['loop']['first'] = false;
if (isset($context['loop']['length'])) {
--$context['loop']['revindex0'];
--$context['loop']['revindex'];
$context['loop']['last'] = 0 === $context['loop']['revindex0'];
}
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['Product'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 196
echo " ";
} else {
// line 197
echo " <span>";
echo twig_escape_filter($this->env, $this->extensions['Symfony\Bridge\Twig\Extension\TranslationExtension']->trans("front.product.search__product_not_found"), "html", null, true);
echo "</span>
";
}
// line 199
echo " </div>
<!-- Pagination -->
<div class=\"pagination-product-list-wrapper\">
<div class=\"pagination-product-list\" style=\"margin: 0 auto;\">
";
// line 203
$this->loadTemplate("Block/_pagination.twig", "Product/list.twig", 203)->display(twig_array_merge($context, ["pages" => twig_get_attribute($this->env, $this->source, (isset($context["pagination"]) || array_key_exists("pagination", $context) ? $context["pagination"] : (function () { throw new RuntimeError('Variable "pagination" does not exist.', 203, $this->source); })()), "paginationData", [], "any", false, false, false, 203)]));
// line 204
echo " </div>
</div>
</div>
</div>
</div>
</body>
";
$__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->leave($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof);
$__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->leave($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof);
}
public function getTemplateName()
{
return "Product/list.twig";
}
public function isTraitable()
{
return false;
}
public function getDebugInfo()
{
return array ( 435 => 204, 433 => 203, 427 => 199, 421 => 197, 418 => 196, 399 => 190, 393 => 188, 390 => 187, 382 => 185, 376 => 183, 373 => 182, 371 => 181, 363 => 176, 359 => 175, 351 => 170, 340 => 168, 335 => 166, 332 => 165, 314 => 164, 312 => 163, 297 => 150, 294 => 149, 286 => 146, 280 => 143, 276 => 142, 272 => 141, 266 => 137, 264 => 136, 261 => 135, 252 => 132, 248 => 131, 244 => 130, 238 => 126, 233 => 125, 231 => 124, 226 => 122, 223 => 121, 218 => 120, 216 => 119, 203 => 109, 194 => 102, 184 => 101, 96 => 21, 86 => 20, 73 => 17, 63 => 16, 52 => 11, 50 => 13, 37 => 11,);
}
public function getSourceContext()
{
return new Source("{#
This file is part of EC-CUBE
Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
http://www.ec-cube.co.jp/
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'default_frame.twig' %}
{% set body_class = 'product_page' %}
{# style #}
{% block stylesheet %}
<link rel=\"stylesheet\" href=\"{{ asset('assets/css/product-list.css') }}\">
{% endblock %}
{% block javascript %}
<script>
(function() {
// Lấy URL hiện tại và tạo URLSearchParams
function getCurrentUrlParams() {
const urlParams = new URLSearchParams(window.location.search);
return urlParams;
}
// Cập nhật URL với category filters và reload
function updateCategoryFilters() {
const checkboxes = document.querySelectorAll('.filter-option__checkbox');
const urlParams = getCurrentUrlParams();
// Xóa tất cả category_filter[] cũ (có thể có nhiều giá trị)
const keysToDelete = [];
urlParams.forEach(function(value, key) {
if (key === 'category_filter[]' || key.startsWith('category_filter')) {
keysToDelete.push(key);
}
});
keysToDelete.forEach(function(key) {
urlParams.delete(key);
});
// Thu thập các category IDs đã được chọn
const selectedCategoryIds = [];
checkboxes.forEach(function(checkbox) {
if (checkbox.checked) {
selectedCategoryIds.push(checkbox.value);
}
});
// Chỉ thêm category_filter[] nếu có ít nhất một checkbox được chọn
if (selectedCategoryIds.length > 0) {
selectedCategoryIds.forEach(function(categoryId) {
urlParams.append('category_filter[]', categoryId);
});
}
// Reset về trang 1 khi filter
urlParams.set('pageno', '1');
// Tạo URL mới
const queryString = urlParams.toString();
const newUrl = queryString
? window.location.pathname + '?' + queryString
: window.location.pathname;
// Reload page với query params mới
window.location.href = newUrl;
}
// Khôi phục trạng thái checkbox từ URL và xử lý nút search
document.addEventListener('DOMContentLoaded', function() {
const checkboxes = document.querySelectorAll('.filter-option__checkbox');
const searchButton = document.querySelector('.btn-search');
// Khôi phục trạng thái checkbox từ URL
const urlParams = getCurrentUrlParams();
const selectedCategories = urlParams.getAll('category_filter[]');
checkboxes.forEach(function(checkbox) {
// Set checked nếu category ID có trong URL
if (selectedCategories.includes(checkbox.value)) {
checkbox.checked = true;
}
// Không lắng nghe sự kiện change trên checkbox nữa
});
// Lắng nghe sự kiện click trên nút search
if (searchButton) {
searchButton.addEventListener('click', function() {
updateCategoryFilters();
});
}
});
})();
</script>
{% endblock %}
{% block main %}
<body>
<!-- breadcrumb section -->
<div class=\"breadcrumb-section\">
<div class=\"container-1360 border-box px-40\">
<nav class=\"breadcrumb\">
<a href=\"#\" class=\"breadcrumb__item text-black\">ホーム</a>
<img src=\"{{ asset('assets/img/default/icons/icon-breadcrumb-arrow.svg') }}\" alt=\">\" class=\"breadcrumb__separator\">
<a href=\"#\" class=\"breadcrumb__item text-black\">商品一覧</a>
</nav>
</div>
</div>
<!-- product list section -->
<div class=\"container-1200\">
<div class=\"product-list-wrapper\">
<div class=\"product-list-left\">
{% if searchable_categories is defined and searchable_categories|length > 0 %}
{% for group in searchable_categories %}
<div class=\"filter-group\">
<div class=\"filter-group__header\">{{ group.parent.name }}</div>
<div class=\"filter-group__options\">
{% if group.children|length > 0 %}
{% for child in group.children %}
<label class=\"filter-option\">
<input type=\"checkbox\"
class=\"filter-option__checkbox\"
name=\"category_filter[]\"
value=\"{{ child.id }}\"
data-category-id=\"{{ child.id }}\">
<span class=\"filter-option__label\">{{ child.name }}</span>
</label>
{% endfor %}
{% else %}
{# Nếu parent category cũng có is_searchable và không có children, hiển thị parent #}
<label class=\"filter-option\">
<input type=\"checkbox\"
class=\"filter-option__checkbox\"
name=\"category_filter[]\"
value=\"{{ group.parent.id }}\"
data-category-id=\"{{ group.parent.id }}\">
<span class=\"filter-option__label\">{{ group.parent.name }}</span>
</label>
{% endif %}
</div>
</div>
{% endfor %}
{% endif %}
<button class=\"btn-primary btn-search w-100\">
<span>検索する</span>
<svg class=\"btn-search-icon\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">
<rect width=\"24\" height=\"24\" rx=\"12\" fill=\"black\"/>
<path d=\"M16.252 12.001L16.249 12.0039L16.252 12.0068L11.7266 16.5312L10.5957 15.4004L13.1943 12.8027H7.72852V11.2031H13.1924L10.5957 8.60742L11.7266 7.47656L16.252 12.001Z\" fill=\"#FBE800\"/>
</svg>
</button>
</div>
<!-- bottom line -->
<div class=\"bottom-line container-mobile\"></div>
<!-- Product List Right -->
<div class=\"product-list-right\">
<div class=\"product-grid\" id=\"product-grid\">
{% if pagination.totalItemCount > 0 %}
{% for Product in pagination %}
<div class=\"product-item\">
<a href=\"{{ url('product_detail', {'id': Product.id}) }}\" class=\"product-card-small\">
<div class=\"product-card-small__image\">
<img src=\"{{ asset(Product.main_list_image|no_image_product, 'save_image') }}\" alt=\"{{ Product.name }}\" {% if loop.index > 5 %} loading=\"lazy\"{% endif %}>
<div class=\"product-card-small__arrow\">
<img src=\"{{ asset('assets/img/default/icons/icon-heart.svg') }}\" alt=\"Favorite\" loading=\"lazy\">
</div>
</div>
</a>
<div class=\"product-item__info\">
<a href=\"{{ url('product_detail', {'id': Product.id}) }}\">
<h4 class=\"product-item__title\">{{ Product.name }}</h4>
</a>
<div class=\"product-item__price\">
<span class=\"price-symbol\">¥</span>
<span class=\"price-amount\">
{% if Product.hasProductClass %}
{% if Product.getPrice02Min == Product.getPrice02Max %}
{{ Product.getPrice02IncTaxMin|price }}
{% else %}
{{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}
{% endif %}
{% else %}
{{ Product.getPrice02IncTaxMin|price }}
{% endif %}
</span>
<span class=\"price-tax\">(税込)</span>
</div>
</div>
</div>
{% endfor %}
{% else %}
<span>{{ 'front.product.search__product_not_found'|trans }}</span>
{% endif %}
</div>
<!-- Pagination -->
<div class=\"pagination-product-list-wrapper\">
<div class=\"pagination-product-list\" style=\"margin: 0 auto;\">
{% include \"Block/_pagination.twig\" with {'pages': pagination.paginationData} %}
</div>
</div>
</div>
</div>
</div>
</body>
{% endblock %}
", "Product/list.twig", "/var/www/html/app/template/default/Product/list.twig");
}
}