antimattr / common-product
此包已被废弃且不再维护。未建议替代包。
通用产品模型
v1.0.1
2014-12-23 22:48 UTC
Requires
- php: >=5.3.2
- doctrine/collections: 1.*
Requires (Dev)
- antimattr/test-case: ~1.0@stable
- fabpot/php-cs-fixer: dev-master
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2018-07-08 19:59:20 UTC
README
AntiMattr通用产品是一个提供共享产品接口的库。
安装
将以下内容添加到您的composer.json文件中
{ "require": { "antimattr/common-product": "~1.0@stable" } }
通过运行以下命令安装库
composer install
如果一切顺利,通用产品现在可以在vendor/antimattr/common-product中找到。
模型
/* * A configurable Product has Attributes (ex. size, color) * Those Attributes have Options (ex. red, blue, small, medium) * A configurable Product has Variations which are unique combinations of Options. */ Product = { attributes: [ Attribute, // color Attribute, // size ], createdAt: Date, currency: string, // USD description: string, dimensionUnit: string, // For Height, Length, Width height: int, // Smallest unit for measurement system id: string || int, images: [ Image, Image, Image, ], length: int, // Smallest unit for measurement system mpn: string, msrp: int, // Smallest unit for currency price: int, // Smallest unit for currency publishedAt: Date, quantity: int, sku: string, status: string, title: string, upc: string, updatedAt: Date, variations: [ Variation, // color_red size_small (an object containing to Variants, one for color red and one for size medium) Variation, // color_red size_medium Variation, // color_red size_large Variation, // color_blue size_small Variation, // color_blue size_medium Variation // color_blue size_large ], weight: int, // Smallest unit for measurement system weigthUnit: string, width: int, // Smallest unit for measurement system }; Attribute { id: 'id', name: 'Color', options: [ Option, // red Option, // orange Option, // yellow Option, // green Option, // blue Option, // indigo Option, // violet ] }; Option { attribute: Attribute, // ReferenceOne value: 'Red', uniqueIdentifier: 'color_red', // Concatenate Attribute name and variant value. This ensures there can be only one "red". variation: Variation, }; Variation extends Product { image: Image, options: [ // A single permutation of options creating a unique mapping of options Option, // color_red Option, // size_medium ], position: int, // Default sort order for Variations, product: Product, // Parent Product uniqueIdentifier: 'color_red_size_medium', // Concatenate Option::uniqueIdentifier };
拉取请求
拉取请求 - PSR标准
请使用pre-commit钩子运行所有代码以符合PSR标准
使用以下命令安装一次
./bin/install.sh
Copying /antimattr-common-product/bin/pre-commit.sh -> /antimattr-common-product/bin/../.git/hooks/pre-commit
拉取请求
拉取请求 - PSR标准
请使用pre-commit钩子修复所有代码以符合PSR标准
使用以下命令安装一次
./bin/install.sh
Copying /antimattr-common-product/bin/pre-commit.sh -> /antimattr-common-product/bin/../.git/hooks/pre-commit
拉取请求 - 测试
请确保测试通过
$ vendor/bin/phpunit tests
拉取请求 - 代码嗅探器和修复器
如果未运行pre-commit钩子,请确保手动运行修复器/嗅探器
$ vendor/bin/php-cs-fixer fix src/ $ vendor/bin/php-cs-fixer fix tests/