obelaw/pim 问题修复 & 功能扩展

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

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

obelaw/pim

Composer 安装命令:

composer require obelaw/pim

包简介

PIM

README 文档

README

A Product Information Management (PIM) package for Laravel.

Installation

You can install the package via composer:

composer require obelaw/pim

Usage

You can use the PIM facade to manage products.

Creating a Simple Product

To create a simple product, use ProductDTO with productType set to 'simple'.

use Obelaw\Pim\Facades\PIM;
use Obelaw\Pim\Data\ProductDTO;

$simpleProductData = new ProductDTO(
    sku: 'TSHIRT-BLUE-M',
    name: 'Blue T-Shirt Medium',
    productType: 'simple',
    price: 19.99,
    description: 'A comfortable blue cotton t-shirt.'
);

$product = PIM::createProduct($simpleProductData);

Creating a Product with Categories

You can assign categories to a product by passing an array of category IDs to the categories parameter in ProductDTO.

use Obelaw\Pim\Facades\PIM;
use Obelaw\Pim\Data\ProductDTO;

$productData = new ProductDTO(
    sku: 'SMART-WATCH-001',
    name: 'Smart Watch',
    productType: 'simple',
    price: 199.99,
    categories: [1, 5] // Array of Category IDs
);

$product = PIM::createProduct($productData);

Creating a Configurable Product

To create a configurable product (e.g., a T-Shirt with multiple sizes/colors), set productType to 'configurable' and provide an array of VariantDTO objects.

use Obelaw\Pim\Facades\PIM;
use Obelaw\Pim\Data\ProductDTO;
use Obelaw\Pim\Data\VariantDTO;

$configurableProductData = new ProductDTO(
    sku: 'TSHIRT-BASE',
    name: 'T-Shirt',
    productType: 'configurable',
    price: 19.99,
    description: 'A basic t-shirt available in multiple sizes.',
    variants: [
        new VariantDTO(
            sku: 'TSHIRT-S',
            price: 19.99,
            stock: 10,
            attributes: [/* Attribute IDs if applicable */]
        ),
        new VariantDTO(
            sku: 'TSHIRT-M',
            price: 19.99,
            stock: 15
        ),
        new VariantDTO(
            sku: 'TSHIRT-L',
            price: 21.99, // Different price for Large
            stock: 5
        ),
    ]
);

$product = PIM::createProduct($configurableProductData);

Retrieving a Product

use Obelaw\Pim\Facades\PIM;

$productResource = PIM::getProduct($id);

Testing

Run the tests with:

composer test

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2026-02-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固