# ProductView

> Một lượt xem sản phẩm gần đây của khách.

Một lượt xem sản phẩm gần đây của khách.

## Trường

| Trường | Kiểu | Mô tả | Từ phiên bản |
|---|---|---|---|
| `product_id` | `string` | Mã sản phẩm đã xem. | 1.0 |
| `product` | [`Product`](/docs/doi-tuong/product/index.md) | Sản phẩm đã dựng sẵn — dùng product.url và product.title để hiển thị. | 1.0 |
| `view_count` | `integer` | Số lần đã xem. | 1.0 |
| `last_viewed_at` | `string` | Lần xem gần nhất (UTC, dạng ISO). | 1.0 |

## Mã đầy đủ

In ra mọi trường của `ProductView`. Đổi `product_view` thành tên biến thật của trang bạn đang viết — xem mục **Xuất hiện ở** bên dưới.

```liquid
{% comment %} Đối tượng ProductView {% endcomment %}
{{ product_view.product_id }}
{% if product_view.product %}
  {% comment %} product_view.product.variants: Variant[] — xem trang Variant {% endcomment %}
  {% comment %} product_view.product.images: Image[] — xem trang Image {% endcomment %}
  {% for item in product_view.product.category_ids %}{{ item }}{% endfor %}
  {{ product_view.product.id }}
  {{ product_view.product.title }}
  {{ product_view.product.slug }}
  {{ product_view.product.url }}
  {{ product_view.product.price | money }}
  {{ product_view.product.compare_at_price | money }}
  {{ product_view.product.cover_image_url }}
  {{ product_view.product.short_description }}
  {{ product_view.product.description }}
  {% for item in product_view.product.tags %}{{ item }}{% endfor %}
  {% comment %} product_view.product.brand: Brand — xem trang Brand {% endcomment %}
  {% comment %} product_view.product.flash: FlashDeal — xem trang FlashDeal {% endcomment %}
  {% for entry in product_view.product.metafields %}{{ entry[0] }}: {{ entry[1] }}{% endfor %}
  {{ product_view.product.sku }}
  {{ product_view.product.rating_avg }}
  {{ product_view.product.review_count }}
  {{ product_view.product.available_quantity }}
  {% if product_view.product.in_stock %}…{% endif %}
  {% comment %} product_view.product.specs: AttributeItem[] — xem trang AttributeItem {% endcomment %}
  {{ product_view.product.promotion_count }}
  {{ product_view.product.default_variant_id }}
  {{ product_view.product.effective_price | money }}
  {{ product_view.product.created_at | date_vi }}
{% endif %}
{{ product_view.view_count }}
{{ product_view.last_viewed_at | date_vi }}
```

## Xuất hiện ở

Những trang dưới đây nhận sẵn một biến mang kiểu `ProductView`.

| Trang | Biến | Kiểu |
|---|---|---|
| [`account/product-views`](/docs/bien-theo-trang/account-product-views/index.md) | `views` | `ProductView[]` |
