# account/product-views

> Sản phẩm khách đã xem gần đây.

Sản phẩm khách đã xem gần đây.

- **Tệp giao diện:** `account/product-views.html`
- **Đường dẫn:** `/tai-khoan/san-pham-da-xem`
- **Controller:** `App\Modules\Account\AccountController::productViewsPage`

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 |
|---|---|---|---|
| `views` | [`ProductView[]`](/docs/doi-tuong/productview/index.md) | Lượt xem, 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/product-views.html` của bộ giao diện mặc định. Chép về `templates/<bộ giao diện của bạn>/account/product-views.html` rồi sửa theo ý muốn.

```liquid
<div class="container page-content">
  <h1 class="page-title">Sản phẩm đã xem</h1>
  <div class="account-layout">
    {% assign active_page = 'views' %}
    {% include 'account/_sidebar' %}
    <div class="account-main">
      {% if views %}
        <div class="product-grid">
          {% for item in views %}
            <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 %}
              <p class="product-card__meta">Xem {{ item.view_count | escape }} lần · lần cuối {{ item.last_viewed_at | date: '%d/%m/%Y' }}</p>
            </div>
          {% endfor %}
        </div>
        {% if has_more %}
          <a href="/tai-khoan/san-pham-da-xem?cursor={{ next_cursor | escape }}" class="btn btn--outline">Xem thêm</a>
        {% endif %}
      {% else %}
        <p class="empty-state">Bạn chưa xem sản phẩm nào.</p>
      {% endif %}
    </div>
  </div>
</div>
```
