Managing Products

Learn how to create and manage Simple and Configurable products using DTOs.

Managing Products

Obelaw PIM supports diverse product structures to fit any business model, primarily distinguishing between Simple and Configurable products.

Product Types

  • Simple Products: Standalone items with single SKUs (e.g., a “One Size” cap, or a unique tool).
  • Configurable Products: Parent products (e.g., “T-Shirt”) that manage multiple child Variants (e.g., “Red/XL”, “Blue/S”).

Creating Products

To ensure data integrity and type safety, Obelaw PIM uses strict Data Transfer Objects (DTOs) for creating products.

Using DTOs and Facades

Use the ProductDTO and VariantDTO classes along with the PIM facade.

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

// Create a Configurable Product
$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
        )
    ]
);

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

Retrieving a Product

use Obelaw\Pim\Facades\PIM;

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

categories

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

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

Media Management

Obelaw PIM uses polymorphic relationships to handle media. You can attach images, videos, or PDF manuals to both Products and Variants.

  • Supports multiple media types per entity.
  • Distinguishes primary images from galleries.

Hierarchical Categories

Categories allow you to organize your catalog with infinite depth. They support parent-child relationships, enabling complex navigation trees (e.g., Electronics > Wearables > Smartwatches).