abderrahimghazali/sylius-upsell-plugin 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

abderrahimghazali/sylius-upsell-plugin

Composer 安装命令:

composer require abderrahimghazali/sylius-upsell-plugin

包简介

Post-purchase upsell and cross-sell plugin for Sylius 2.x — Frequently Bought Together, one-click add-all-to-cart

README 文档

README

Sylius Logo

Sylius Upsell Plugin

Post-purchase upsell and cross-sell plugin for Sylius 2.x stores — Frequently Bought Together, checkout upsell modals, and one-click add-all-to-cart.

CI Latest Version PHP Version License Sylius 2.x Symfony 7.x PHPStan Level 7

Screenshots

Admin — Upsell Offers Grid

Admin Offers Grid

Admin — Upsell Offer Form

Admin Offer Form

Shop — Checkout Upsell Modal

Checkout Upsell Modal

Admin — Upsell Analytics Dashboard

Admin Analytics

Features

  • Frequently Bought Together section on every product page with manual or algorithmic product suggestions
  • One-click add-all-to-cart for the entire FBT bundle
  • Algorithmic co-purchase detection from order history with configurable thresholds
  • Checkout upsell modal — intercepts "Place order" with a special offer before completing the order
  • Trigger product targeting — tie offers to specific products in the cart, or use catch-all
  • Discount percentage — upsell product added to cart at discounted price
  • Customizable copy — headline, body, CTA label, and decline label per offer
  • Date scheduling — start and end dates for time-limited offers
  • Priority system — control which offer wins when multiple match
  • Admin CRUD for upsell offers under Marketing, and global FBT settings under Configuration
  • Drag-and-drop reordering of manual FBT relations with optional discount badges
  • Analytics dashboard — impressions, acceptance rate, extra revenue, daily chart (Chart.js)
  • Impression tracking — automatic for both FBT and checkout upsell (shown / accepted / declined)

Requirements

  • Sylius 2.1+
  • Symfony 7.0+
  • PHP 8.2+

Installation

  1. Require the plugin:
composer require abderrahimghazali/sylius-upsell-plugin
  1. Register the bundle in config/bundles.php (if not auto-discovered):
return [
    // ...
    Abderrahim\SyliusUpsellPlugin\SyliusUpsellPlugin::class => ['all' => true],
];
  1. Import routes — create config/routes/sylius_upsell.yaml:
sylius_upsell:
    resource: '@SyliusUpsellPlugin/config/routes.yaml'
  1. Generate and run the migration:
bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate
  1. Register the Stimulus controllers in assets/shop/controllers.json:
{
    "controllers": {
        "@abderrahimghazali/sylius-upsell-plugin": {
            "fbt": {
                "enabled": true,
                "fetch": "eager"
            },
            "post-purchase": {
                "enabled": true,
                "fetch": "eager"
            }
        }
    }
}
  1. Symlink the plugin assets and rebuild:

Add to your project's package.json dependencies:

"@abderrahimghazali/sylius-upsell-plugin": "file:vendor/abderrahimghazali/sylius-upsell-plugin/assets"

Then install and rebuild:

npm install
npm run build

Entity: UpsellRelation

Field Type Description
sourceProduct ManyToOne (Product) The product page where the FBT section appears
relatedProduct ManyToOne (Product) The product suggested alongside the source
position int Display order (lower = first)
discount int? Optional discount percentage for the related product
createdAt datetime Timestamp of creation

Entity: UpsellOffer

Field Type Description
name string Admin label for the offer
enabled boolean Active/inactive toggle
triggerProduct ManyToOne (Product) The purchased product that triggers this offer
offerProduct ManyToOne (Product) The product offered in the upsell modal
offerVariant ManyToOne (ProductVariant)? Optional specific variant to offer
discountPercent int Discount percentage shown in the modal
headline string Modal heading (default: "Wait! A special offer just for you")
body text? Optional body text
ctaLabel string Accept button text (default: "Yes, add it!")
declineLabel string Decline button text (default: "No thanks")
priority int Higher = shown first when multiple offers match
startsAt datetime? Optional start date
endsAt datetime? Optional end date

Entity: UpsellConfiguration

Field Type Description
enabled boolean Global FBT feature toggle
minCoPurchaseThreshold int Minimum co-purchase count for algorithmic suggestions (default: 3)
maxProductsShown int Maximum products in the FBT section (default: 4)
sectionTitle string Heading text (default: "Frequently bought together")
showDiscountBadge boolean Show/hide discount badges on FBT products
fallbackStrategy string algorithmic, manual_only, or disabled

Architecture

src/
├── Controller/
│   ├── Admin/
│   │   ├── UpsellConfigurationController.php    # Global FBT settings
│   │   └── UpsellOfferController.php            # CRUD for upsell offers
│   └── Shop/
│       ├── ImpressionController.php             # Impression tracking API
│       └── PostPurchaseController.php           # Accept/decline offer API
├── DependencyInjection/
│   ├── Configuration.php
│   └── SyliusUpsellExtension.php                # Prepends resources, grids, hooks
├── Entity/
│   ├── UpsellConfiguration.php
│   ├── UpsellImpression.php
│   ├── UpsellOffer.php
│   ├── UpsellOfferInterface.php
│   ├── UpsellRelation.php
│   └── UpsellRelationInterface.php
├── EventListener/
│   ├── AdminMenuListener.php                    # Marketing menu items
│   └── ProductFormListener.php                  # FBT tab on product form
├── Form/Type/
│   ├── ProductUpsellType.php                    # Product FBT relations form
│   ├── UpsellConfigurationType.php              # Global settings form
│   ├── UpsellOfferType.php                      # Upsell offer form
│   └── UpsellRelationType.php                   # Single relation row form
├── Repository/
│   ├── UpsellImpressionRepository.php           # Analytics queries
│   ├── UpsellOfferRepository.php                # Active offers query
│   └── UpsellRelationRepository.php             # Relations by product
├── Service/
│   ├── FrequentlyBoughtTogetherResolver.php     # FBT logic (manual + algorithmic)
│   ├── PostPurchaseOfferResolver.php            # Best matching offer for an order
│   ├── UpsellAnalyticsService.php               # Impression recording + analytics
│   └── UpsellConfigurationProvider.php          # Cached config access
├── Twig/UpsellExtension.php                     # Twig function bridge
└── SyliusUpsellPlugin.php                       # Bundle class

assets/
├── controllers/
│   ├── fbt-controller.js                        # Add-all-to-cart Stimulus controller
│   └── post-purchase-controller.js              # Upsell modal Stimulus controller
└── package.json

templates/
├── Admin/
│   ├── analytics.html.twig                      # Analytics dashboard with Chart.js
│   ├── configuration.html.twig                  # Global settings page
│   └── upsell_offer/
│       ├── create.html.twig
│       ├── update.html.twig
│       └── grid/field/product.html.twig
└── Shop/
    ├── frequently_bought_together.html.twig     # FBT section on product page
    └── post_purchase_offer.html.twig            # Upsell modal after checkout

Testing

vendor/bin/phpunit

License

MIT. See LICENSE.

abderrahimghazali/sylius-upsell-plugin 适用场景与选型建议

abderrahimghazali/sylius-upsell-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 03 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「ecommerce」 「analytics」 「sylius」 「sylius-plugin」 「Upsell」 「cross-sell」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 abderrahimghazali/sylius-upsell-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 abderrahimghazali/sylius-upsell-plugin 我们能提供哪些服务?
定制开发 / 二次开发

基于 abderrahimghazali/sylius-upsell-plugin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 23
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 41
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-28