定制 dynamic/silverstripe-product-wishlist 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

dynamic/silverstripe-product-wishlist

Composer 安装命令:

composer require dynamic/silverstripe-product-wishlist

包简介

adds a product wish list to your website

关键字:

README 文档

README

Build Status codecov Scrutinizer Code Quality Build Status

product-wishlist

Allows users to create and manage a wish list on a website.

Requirements

  • silverstripe/recipe-cms ^4.0
  • dynamic/viewable-dataobject ^2.0
  • dynamic/silverstripe-additional-formfields ^2.0
  • dynamic/silverstripe-manageable-dataobject ^2.0

Installation

composer require dynamic/silverstripe-product-wishlist

Example usage

This module was not hooked up with any particular module that adds products to allow flexibility. The examples here will use FoxyStripe.

ProductWishList Extension

A product relation must be added to Dynamic\Wishlist\Model\ProductWishList through a DataExtension.

Dynamic\Wishlist\Model\ProductWishList:
  extensions:
    - Foo\Bar\ORM\WishListExtension
<?php

namespace Foo\Bar\ORM;

use Dynamic\FoxyStripe\Page\ProductPage;
use SilverStripe\ORM\DataExtension;

class WishListExtension extends DataExtension
{
    /**
     * @var array
     */
    private static $many_many = [
        'Products' => ProductPage::class,
    ];
}

Product Relation

The Product must also have a reciprocal relation to wishlists.

Dynamic\FoxyStripe\Page\ProductPage:
  extensions:
    - Foo\Bar\ORM\ProductExtension
<?php

namespace Foo\Bar\ORM;

use Dynamic\Wishlist\Model\ProductWishList;

class ProductExtension extends DataExtension
{
    /**
     * @var array
     */
    private static $belongs_many_many = [
        'WishLists' => ProductWishList::class,
    ];
}

WishList Form

The ProductControllerExtension should be applied to the controller that handles showing a product.

Dynamic\FoxyStripe\Page\ProductPageController:
  extensions:
    - Dynamic\Wishlist\Extensions\ProductControllerExtension

The form can be passed a product id to avoid using the current controller's page id. The form will not show if the user is not logged in.

AddToWishListForm and RemoveFromWishListForm

The only real difference between these forms are the actions the forms call and an extra class.

updateWishLists

An extension point for updating the wishlists visible in the dropdown field. It is passed a DataList of the wishlists associated with the current user.

/**
 * @param SilverStripe\ORM\DataList $lists
 */
public function updateWishLists($lists)
{
    // Stuff here
}
updateFields

An extension point for updating the fields for the form. It is passed a FieldList and an int.

/**
 * @param SilverStripe\Forms\FieldList $fields
 * @param int $productID
 */
public function updateFields($fields, $productID)
{
    // Stuff here
}
updateActions

An extension point for updating the actions for the form. It is passed a FieldList and an int.

/**
 * @param SilverStripe\Forms\FieldList $actions
 * @param int $productID
 */
public function updateActions($actions, $productID)
{
    // Stuff here
}

WishList Form Handling

Handling the addToWishList and removeFromWishList actions is not included by default. The example implementations should be on a controller, or an extension applied to a controller.

addToWishList Example

/**
 * @param $data
 * @param \SilverStripe\Forms\Form $form
 * @return \SilverStripe\Control\HTTPResponse
 * @throws \Exception
 */
public function addToWishList($data, Form $form)
{
    /** @var ProductWishList|\Foo\Bar\Extension\WishListExtension $list */
    $list = ProductWishList::get()->filter([
        'ID' => $data['List'],
    ])->first();

    $list->Products()->add($data['ProductID']);

    return $this->owner->redirectBack();
}

removeFromWishList Example

/**
 * @param $data
 * @param \SilverStripe\Forms\Form $form
 * @return \SilverStripe\Control\HTTPResponse
 * @throws \Exception
 */
public function removeFromWishList($data, Form $form)
{
    /** @var ProductWishList|\Foo\Bar\Extension\WishListExtension $list */
    $list = ProductWishList::get()->filter([
        'ID' => $data['List'],
    ])->first();

    $list->Products()->removeByID($data['ProductID']);

    return $this->owner->redirectBack();
}

Documentation

See the docs/en folder.

dynamic/silverstripe-product-wishlist 适用场景与选型建议

dynamic/silverstripe-product-wishlist 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 64 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 10 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 dynamic/silverstripe-product-wishlist 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2022-10-04