定制 setono/sylius-order-edit-plugin 二次开发

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

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

setono/sylius-order-edit-plugin

最新稳定版本:v1.0.0

Composer 安装命令:

composer require setono/sylius-order-edit-plugin

包简介

Setono example plugin for Sylius.

README 文档

README

Latest Version Software License Build Status Code Coverage Mutation testing

Edit orders inside your admin interface.

Install

composer require setono/sylius-order-edit-plugin

Import routing

# config/routes/setono_sylius_order_edit.yaml
setono_sylius_order_edit:
    resource: "@SetonoSyliusOrderEditPlugin/Resources/config/routes.yaml"

If you're using Sylius <=1.10, also import additional product variant routes:

setono_sylius_order_edit_product_variant:
    resource: "@SetonoSyliusOrderEditPlugin/Resources/config/routes/product_variant.yaml"

and remember to add the referenced ProductVariantRepository methods (findByCodes and findByPhrase).

Extend the Order entity

<?php

declare(strict_types=1);

namespace App\Entity\Order;

use Doctrine\ORM\Mapping as ORM;
use Setono\SyliusOrderEditPlugin\Entity\EditableOrderInterface;
use Setono\SyliusOrderEditPlugin\Entity\EditableOrderTrait;
use Sylius\Component\Core\Model\Order as BaseOrder;

#[ORM\Entity]
#[ORM\Table(name: 'sylius_order')]
class Order extends BaseOrder implements EditableOrderInterface
{
    use EditableOrderTrait;
}

Update your database schema

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

The plugin adds a new field to the Order entity named initialTotal which will contain the order total and is used when editing orders.

To set the initialTotal field for existing orders, you can add the following to your migration:

<?php
// ...

public function up(Schema $schema): void
{
    // ...
    $this->addSql('UPDATE sylius_order SET initial_total = total');
}

// ...

Done!

You should be able to edit orders in your admin interface. Enjoy 🎉

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-27