PHPackages                             tourze/product-collect-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tourze/product-collect-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

tourze/product-collect-bundle
=============================

商品收藏模块 - 提供用户商品收藏功能

0.0.1(5mo ago)00MITPHPPHP ^8.2CI passing

Since Nov 14Pushed 4mo agoCompare

[ Source](https://github.com/tourze/product-collect-bundle)[ Packagist](https://packagist.org/packages/tourze/product-collect-bundle)[ RSS](/packages/tourze-product-collect-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (37)Versions (2)Used By (0)

ProductCollectBundle
====================

[](#productcollectbundle)

[English](README.md) | [中文](README.zh-CN.md)

商品收藏模块 - 提供用户商品收藏功能

功能特性
----

[](#功能特性)

- 🔖 商品收藏管理（添加、取消、恢复）
- 📁 收藏分组功能
- 📌 置顶收藏支持
- 🔢 自定义排序
- 📊 收藏统计分析
- 🚀 批量操作支持
- 💾 软删除机制

安装
--

[](#安装)

```
composer require tourze/product-collect-bundle
```

使用示例
----

[](#使用示例)

### 基本收藏操作

[](#基本收藏操作)

```
use Tourze\ProductCollectBundle\Service\ProductCollectService;

// 添加收藏
$collect = $collectService->addToCollection($userId, $skuId, '我的收藏', '备注信息');

// 切换收藏状态
$result = $collectService->toggleCollection($userId, $skuId);

// 检查是否已收藏
$isCollected = $collectService->isCollected($userId, $skuId);

// 获取用户收藏列表
$collections = $collectService->getUserActiveCollections($userId);
```

### 分组管理

[](#分组管理)

```
// 按分组获取收藏
$collections = $collectService->getUserCollectionsByGroup($userId, '我的最爱');

// 获取用户所有分组
$groups = $collectService->getUserCollectionGroups($userId);

// 批量移动到分组
$results = $collectService->moveToGroup($userId, [$skuId1, $skuId2], '新分组');
```

### 高级功能

[](#高级功能)

```
// 获取置顶收藏
$topCollections = $collectService->getTopCollections($userId, 10);

// 获取最近收藏
$recentCollections = $collectService->getRecentCollections($userId, 20);

// 获取热门商品
$popularSkus = $collectService->getPopularSkus(50);

// 收藏统计
$stats = $collectService->getCollectionStatistics();
```

实体结构
----

[](#实体结构)

### ProductCollect

[](#productcollect)

核心收藏实体，包含以下字段：

- `id`: 雪花ID主键
- `userId`: 用户ID（字符串类型）
- `sku`: 关联的SKU实体
- `status`: 收藏状态（活跃/取消/隐藏）
- `collectGroup`: 收藏分组
- `note`: 收藏备注
- `sortNumber`: 排序权重
- `isTop`: 是否置顶
- `metadata`: 扩展元数据
- `createdAt/updatedAt`: 时间戳

### CollectStatus 枚举

[](#collectstatus-枚举)

- `ACTIVE`: 已收藏
- `CANCELLED`: 已取消
- `HIDDEN`: 已隐藏

数据库索引
-----

[](#数据库索引)

系统自动创建以下索引以优化查询性能：

- `uniq_user_sku`: 用户和SKU的唯一约束
- `idx_user_status`: 用户ID和状态索引
- `idx_collect_group`: 收藏分组索引
- `idx_sort_top`: 置顶和排序索引
- `idx_created_at`: 创建时间索引

许可证
---

[](#许可证)

MIT License

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance72

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

179d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e354fdb316da535dfa8ba2e9193a473c403b6bc6fb9170778d1dc50e304c6e9d?d=identicon)[tourze](/maintainers/tourze)

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-product-collect-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-product-collect-bundle/health.svg)](https://phpackages.com/packages/tourze-product-collect-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
