PHPackages                             vbpupil/product - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. vbpupil/product

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

vbpupil/product
===============

Product Library

5.0.0(5y ago)03921[1 PRs](https://github.com/vbpupil/product-library/pulls)MITPHPPHP &gt;=7.2CI passing

Since Nov 6Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/vbpupil/product-library)[ Packagist](https://packagist.org/packages/vbpupil/product)[ RSS](/packages/vbpupil-product/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (4)Versions (38)Used By (0)

Quality Assurance
-----------------

[](#quality-assurance)

[![PHP 7.2](https://camo.githubusercontent.com/5180a354acf28fb748fbeddd95219b60e0145d1e0eac9f976ca9a1bc9bc0337b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e322d626c75652e737667)](https://camo.githubusercontent.com/5180a354acf28fb748fbeddd95219b60e0145d1e0eac9f976ca9a1bc9bc0337b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e322d626c75652e737667)

ProductLibrary
==============

[](#productlibrary)

A Product Object can have many components based on how complicated your requirements are. Below outlines the general configurations:

### SimpleProduct - Without Prices

[](#simpleproduct---without-prices)

A SimpleProduct does NOT have any prices. Below shows how a SimpleProduct can be initiated:

```
$prod = new SimpleProduct(
    'Iphone X',
    new Collection()
);

$prod->setLive(true);

$prod->setSlug('iphone-x'); //defines urls safe string

$prod->setDescription(
    'The iPhone X, pronounced "iPhone 10," was introduced at Apple\'s September 2017 event as a classic "One more thing...".',
    'long_description');
```

#### Get Description

[](#get-description)

```
echo $prod->getItem('long_description');
```

#### Get Descriptions

[](#get-descriptions)

```
foreach ($prod->getItems() as $desc) {
    echo $desc;
}
```

#### Get Product Attributes

[](#get-product-attributes)

- getBrandName() - brand name associated with product
- getBrandId() - brand id associated with product

### GeneralProduct

[](#generalproduct)

On the face of it a General Product is the same as a Simple Product except it has a concept of Variations which itself offers some interesting additions.

To add Variations simplly start by passing in an empty Collection:

```
$prod->setVariations(
        new Collection()
    );
```

Once you have created the Collection simply use it as you would any other Collection object (the above descriptions functionality in Simple Product uses the same functionality).

To add a Variation:

```
    $myVariation = new \vbpupil\Variation\AbstractVariation(
            [
                'title' => 'FFF',
                'product_code' => 'MYPRODCODE-01'
            ]
        );

    $prod->variations->addItem($v);
```

#### Get Variant Attributes

[](#get-variant-attributes)

- getBarcode() - barcode of a variant
- getEan() - ean of a variant
- getMpn() - mpn of a variant
- getPriceType() - price type of a variant ie single or pivot
- getUnitOfSale() - unit of sale of a varient ie bag, pallet, jumbo bag etc
- getMinDelQty() - how much qty to purchase before del is available
- getMaxDelQty() - how much qty is too much before only colection is available

Pricing
-------

[](#pricing)

### SinglePrice

[](#singleprice)

This handles most use cases when a product variation may have a few prices attributed to it such as prices, special prices, cost prices etc but will only be sold for a single prices. When asking the object for its **getPrice()**method you will be returned a single prices. Note the object will run a check to see if the Special prices is set/valid and return that if true, if not the sell prices will be returned.

### PivotPrice

[](#pivotprice)

This object will handle the pivot prices style structure, ie:

QtyPrice1 - 95.0010 - 194.0020 - 303.00to identify which price type a variant is (ie single or pivot) you can use **getVariantPriceTypes()**
to identify which is the cheapest variant id you can use **getCheapestVariantiD()**to identify which is the cheapest variant price you can use **getCheapestVariantPrice()**

Stock
-----

[](#stock)

Stock can be measured depending upon needs, the following are available.

### SimpleStock

[](#simplestock)

Simple stock offers a simple holding of a stock figure and passes back whenever called upon.

### AuditableStock

[](#auditablestock)

Auditable stock has the ability to verify what the current stock figure has on hand by performing a retrospective check of its inventory history and spitting out its findings.

### Auditable

[](#auditable)

The auditable class is on hand to offer an explanation of why an items stock figure has changed - ie BOOK\_IN/BOOK\_OUT etc etc.

### AuditableType

[](#auditabletype)

This class simply defines what can be accepted as a valid reason. For instance when newing up an Auditable:

```
$a = new Auditable(
            2,
            AuditableType::SALE(),
            'Sold',
            '2019-08-22 14:42:20',
            AuditableAssociatedDocumentType::SALES_ORDER(),
            115
        )
```

A **AuditableType::SALE()** is passed into to represent a SALE item. This class is governed by Enums which outlines what type is available.

### AuditableAssociatesDocumentType

[](#auditableassociatesdocumenttype)

This class allows you to specify what supporting document accompanies the stock change, for instance a SALES\_ORDER (with accompanying SALES ORDER ID) would support a sale which resulted in the stock being reduced by 1. Below shows this code in action.

```
$a = new Auditable(
            2,
            AuditableType::SALE(),
            'Sold',
            '2019-08-22 14:42:20',
            AuditableAssociatedDocumentType::SALES_ORDER(),
            115
        )
```

An **AuditableAssociatedDocumentType::SALES\_ORDER()** is passed in to represent a SALES\_ORDER. This class is governed by Enums which outlines what supporting document types are available.

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance57

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~12 days

Total

30

Last Release

1902d ago

Major Versions

1.3.0 → 2.0.02020-04-28

2.0.0 → 3.0.02020-09-29

3.0.3 → 4.0.02021-01-25

4.1.2 → 5.0.02021-02-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/afdce7c1b24b3c017b5381c2708b9dd27b9b694de9b09b49ee500a26d3f46364?d=identicon)[vbpupil](/maintainers/vbpupil)

---

Top Contributors

[![vbpupil](https://avatars.githubusercontent.com/u/2638990?v=4)](https://github.com/vbpupil "vbpupil (80 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vbpupil-product/health.svg)

```
[![Health](https://phpackages.com/badges/vbpupil-product/health.svg)](https://phpackages.com/packages/vbpupil-product)
```

###  Alternatives

[sylius/refund-plugin

Plugin provides basic refunds functionality for Sylius application.

691.7M13](/packages/sylius-refund-plugin)[seboettg/citeproc-php

Full-featured CSL processor (https://citationstyles.org)

761.2M19](/packages/seboettg-citeproc-php)[timeweb/phpstan-enum

Enum class reflection extension for PHPStan

443.2M21](/packages/timeweb-phpstan-enum)[php-unit-conversion/php-unit-conversion

A fully PSR-4 compatible PHP library for converting between standard units of measure.

681.2M1](/packages/php-unit-conversion-php-unit-conversion)[open-feature/sdk

PHP implementation of the OpenFeature SDK

39514.9k15](/packages/open-feature-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
