PHPackages                             tourze/product-recommend-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-recommend-bundle

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

tourze/product-recommend-bundle
===============================

一个用于管理商品推荐位、推荐元素和关联推荐的 Symfony Bundle

0.0.3(5mo ago)02MITPHPCI passing

Since Nov 14Pushed 4mo agoCompare

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

READMEChangelog (3)Dependencies (32)Versions (4)Used By (0)

Product Recommend Bundle
========================

[](#product-recommend-bundle)

[![PHP Version](https://camo.githubusercontent.com/cc9cdea9aa96b40a822425e981b0a030e3371202973c7d57b74e8e99834f81dc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d626c7565)](https://www.php.net/)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](LICENSE)[![Symfony](https://camo.githubusercontent.com/b951f3ba5cfbe96f333da1d119cbb038aee1ca71e7239a28e7eedcd02ef96b8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73796d666f6e792d253545362e342d626c7565)](https://symfony.com/)[![Build Status](https://camo.githubusercontent.com/b0c6c6845a74cb65a7f0a32bdcfd8fbf80eeb40026c4029af424ab371c94b8bd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275696c642d70617373696e672d627269676874677265656e)](https://github.com/your-repo/actions)[![Code Coverage](https://camo.githubusercontent.com/32855e94577df9d0a30995653b17d33a5fbfdf644518f96ea0374313397d19b7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d627269676874677265656e)](https://codecov.io/gh/your-repo)

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

A comprehensive Symfony bundle for managing product recommendations with flexible recommend blocks, product elements, tags, and related recommendations.

Features
--------

[](#features)

- **Recommend Blocks**: Organize recommendations by blocks with title and subtitle
- **Product Elements**: Manage individual product recommendations with SPU IDs, images, and reasons
- **Element Tags**: Categorize recommendations with flexible tagging system
- **Related Recommendations**: Create product-to-product relationship recommendations
- **EasyAdmin Integration**: Built-in admin controllers for easy management
- **Doctrine Support**: Full ORM integration with timestamp, user tracking, and snowflake ID support

Installation
------------

[](#installation)

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

Quick Start
-----------

[](#quick-start)

### 1. Enable the Bundle

[](#1-enable-the-bundle)

Add the bundle to your `config/bundles.php`:

```
return [
    // ...
    ProductRecommendBundle\ProductRecommendBundle::class => ['all' => true],
];
```

### 2. Configure Database

[](#2-configure-database)

Run migrations to create the required tables:

```
php bin/console doctrine:migrations:migrate
```

### 3. Basic Usage

[](#3-basic-usage)

```
use ProductRecommendBundle\Entity\RecommendBlock;
use ProductRecommendBundle\Entity\RecommendElement;

// Create a recommendation block
$block = new RecommendBlock();
$block->setTitle('Featured Products');
$block->setSubtitle('Our top recommendations');
$block->setValid(true);

// Add products to the block
$element = new RecommendElement();
$element->setBlock($block);
$element->setSpuId('12345');
$element->setThumb('/images/product.jpg');
$element->setTextReason('Best seller this month');
$element->setValid(true);

$entityManager->persist($block);
$entityManager->persist($element);
$entityManager->flush();
```

Administration
--------------

[](#administration)

The bundle includes EasyAdmin CRUD controllers for managing:

- `ProductRecommendBlockCrudController` - Manage recommendation blocks
- `ProductRecommendElementCrudController` - Manage product elements
- `ProductRecommendElementTagCrudController` - Manage element tags
- `ProductRecommendRelatedCrudController` - Manage related recommendations

Configuration
-------------

[](#configuration)

The bundle provides sensible defaults and minimal configuration requirements.

### Basic Configuration

[](#basic-configuration)

Add to your `config/packages/product_recommend.yaml`:

```
product_recommend:
    # Optional: Configure default scoring
    default_score: 1.0
    # Optional: Configure max text reason length
    max_text_reason_length: 500
```

### Database Configuration

[](#database-configuration)

Ensure your database connection is properly configured in `config/packages/doctrine.yaml`.

Dependencies
------------

[](#dependencies)

This bundle requires the following packages:

### Core Dependencies

[](#core-dependencies)

- `symfony/framework-bundle ^6.4`
- `doctrine/orm ^3.0`
- `doctrine/doctrine-bundle ^2.13`

### Tourze Dependencies

[](#tourze-dependencies)

- `tourze/doctrine-snowflake-bundle` - For snowflake ID generation
- `tourze/doctrine-timestamp-bundle` - For automatic timestamps
- `tourze/doctrine-user-bundle` - For user tracking
- `tourze/easy-admin-extra-bundle` - For enhanced admin interface

### Optional Dependencies

[](#optional-dependencies)

- `knplabs/knp-menu ^3.7` - For menu integration

Advanced Usage
--------------

[](#advanced-usage)

### Custom Repository Usage

[](#custom-repository-usage)

```
use ProductRecommendBundle\Repository\RecommendBlockRepository;
use ProductRecommendBundle\Repository\RecommendElementRepository;

// Get repository
$blockRepo = $entityManager->getRepository(RecommendBlock::class);
$elementRepo = $entityManager->getRepository(RecommendElement::class);

// Find active blocks
$activeBlocks = $blockRepo->findBy(['valid' => true]);

// Find elements by block
$elements = $elementRepo->findBy(['block' => $block, 'valid' => true]);
```

### Working with Tags

[](#working-with-tags)

```
use ProductRecommendBundle\Entity\RecommendElementTag;

// Create and assign tags
$tag = new RecommendElementTag();
$tag->setTitle('Hot Deal');
$tag->setValid(true);

$element->addRecommendElementTag($tag);
```

### Related Recommendations

[](#related-recommendations)

```
use ProductRecommendBundle\Entity\RelatedRecommend;

// Create product-to-product recommendations
$related = new RelatedRecommend();
$related->setVisitSpuId('12345');
$related->setScene('product_detail');
$related->setRecommendSpuId('67890');
$related->setTextReason('Customers who viewed this also liked');
$related->setScore(0.8);
$related->setValid(true);
```

### Performance Optimization

[](#performance-optimization)

- Use `fetch: 'EXTRA_LAZY'` for large collections
- Implement caching for frequently accessed recommendations
- Consider pagination for large result sets

### Validation

[](#validation)

All entities include comprehensive validation constraints:

- **Length validation** for all string fields
- **Format validation** for SPU IDs (numeric strings)
- **URL validation** for image thumbnails
- **Range validation** for scores (0-100)

License
-------

[](#license)

This bundle is released under the MIT license. See the [LICENSE](LICENSE) file for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance72

Regular maintenance activity

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity27

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

Every ~2 days

Total

3

Last Release

173d 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-recommend-bundle/health.svg)

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

###  Alternatives

[sylius/sylius

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

8.4k5.6M650](/packages/sylius-sylius)[sulu/sulu

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

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[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)
