# account/saved-products

> Sản phẩm khách đã lưu.

Sản phẩm khách đã lưu.

- **Tệp giao diện:** `account/saved-products.html`
- **Đường dẫn:** `/tai-khoan/san-pham-yeu-thich`
- **Controller:** `App\Modules\Account\AccountController::savedProductsPage`

Ngoài những biến dưới đây, slot này còn nhận toàn bộ [biến toàn cục](/docs/bien-toan-cuc/index.md).

## Biến của trang

| Biến | Kiểu | Mô tả | Từ phiên bản |
|---|---|---|---|
| `products` | [`SavedProduct[]`](/docs/doi-tuong/savedproduct/index.md) | Sản phẩm đã lưu, mỗi mục kèm đối tượng product đã dựng sẵn. | 1.0 |
| `has_more` | `boolean` | Còn trang tiếp theo hay không. | 1.0 |
| `next_cursor` | `string` \| `null` | Con trỏ để tải trang kế; null khi đã hết. | 1.0 |

## Mã đầy đủ

Toàn bộ tệp `account/saved-products.html` của bộ giao diện mặc định. Chép về `templates/<bộ giao diện của bạn>/account/saved-products.html` rồi sửa theo ý muốn.

```liquid
<div class="container page-content">
  <h1 class="page-title">Sản phẩm yêu thích</h1>
  <div class="account-layout">
    {% assign active_page = 'saved' %}
    {% include 'account/_sidebar' %}
    <div class="account-main">
      {% if products %}
        <div class="product-grid">
          {% for item in products %}
            <div class="product-card">
              {% if item.product.url %}
                <a href="{{ item.product.url | escape }}" class="product-card__link">{{ item.product.title | escape }}</a>
              {% else %}
                <span class="product-card__link">{{ item.product.title | escape }}</span>
              {% endif %}
              <form method="POST" action="/tai-khoan/san-pham-yeu-thich/{{ item.product_id | escape }}/xoa" onsubmit="return confirm('Bỏ yêu thích?')">
                <input type="text" name="_hp" style="display:none" tabindex="-1" autocomplete="off">
                <button class="btn btn--outline btn--sm" type="submit">Bỏ lưu</button>
              </form>
            </div>
          {% endfor %}
        </div>
        {% if has_more %}
          <a href="/tai-khoan/san-pham-yeu-thich?cursor={{ next_cursor | escape }}" class="btn btn--outline">Xem thêm</a>
        {% endif %}
      {% else %}
        <p class="empty-state">Bạn chưa lưu sản phẩm nào.</p>
      {% endif %}
    </div>
  </div>
</div>
```
