Simple Product Structure
Simple Product Overview
Simple products are standalone physical items with a single SKU:
-- Product entity
SELECT entity_id, sku, type_id, attribute_set_id
FROM catalog_product_entity
WHERE type_id = 'simple'
LIMIT 5;
+-----------+--------------+-----------+------------------+
| entity_id | sku | type_id | attribute_set_id |
+-----------+--------------+-----------+------------------+
| 1 | TSHIRT-001 | simple | 4 |
| 2 | TSHIRT-002 | simple | 4 |
| 3 | MUG-001 | simple | 5 |
| 4 | PHONE-001 | simple | 6 |
| 5 | LAPTOP-001 | simple | 6 |
+-----------+--------------+-----------+------------------+
Simple Product Attributes
// Core attributes
$product->getId(); // Entity ID
$product->getSku(); // SKU (unique)
$product->getName(); // Name
$product->getPrice(); // Base price
$product->getSpecialPrice(); // Discounted price
$product->getTaxClassId(); // Tax class
$product->getStatus(); // 1=enabled, 2=disabled
$product->getVisibility(); // 1=not visible, 2=catalog, 3=search, 4=both
// Inventory
$product->getStockData(); // Stock information
$product->getQuantityAndStockStatus();
// Physical
$product->getWeight(); // Weight
$product->getDimension(); // Custom dimensions
Product Creation
// Create simple product
$product = $objectManager->get(
\Magento\Catalog\Model\ProductFactory::class
)->create();
$product->setName('Blue T-Shirt')
->setSku('TSHIRT-BLUE-001')
->setPrice(29.99)
->setStatus(1)
->setVisibility(4)
->setAttributeSetId(4)
->setTypeId('simple')
->setStockData([
'use_config_manage_stock' => 1,
'qty' => 100,
'is_in_stock' => 1,
])
->save();
SKU Management
SKU Properties
-- SKU is stored in varchar value table
SELECT value_id, entity_id, store_id, value AS sku
FROM catalog_product_entity_varchar
WHERE attribute_id = 77 -- sku attribute_id
LIMIT 5;
+----------+-----------+----------+--------------+
| value_id | entity_id | store_id | sku |
+----------+-----------+----------+--------------+
| 123 | 1 | 0 | TSHIRT-001 |
| 124 | 2 | 0 | TSHIRT-002 |
| 125 | 3 | 0 | MUG-001 |
+----------+-----------+----------+--------------+
SKU Validation
// Check SKU uniqueness
$productRepository = $objectManager->get(
\Magento\Catalog\Api\ProductRepositoryInterface::class
);
try {
$existingProduct = $productRepository->get('TSHIRT-001');
// SKU exists
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
// SKU is available
}
// Auto-generate SKU
$skuGenerator = $objectManager->get(
\Magento\Catalog\Model\Product\Url::class
);
$autoSku = $this->generateSku($product);
SKU Configuration
// SKU can be same as URL key
$product->setUrlKey($product->getSku());
// SKU prefix/suffix
$prefix = 'VND-';
$suffix = '-001';
$sku = $prefix . $product->getName() . $suffix;
// SKU patterns
// TSHIRT-001 → Product code + sequence
// TSHIRT-BLUE-L → Product code + variant + size
// PHONE-15-PRO-256 → Product + model + storage
Inventory Management
Inventory Tables
-- inventory_source_stock (MSI)
SELECT source_code, qty, is_salable
FROM inventory_source_stock
WHERE sku = 'TSHIRT-001';
+-------------+------+-----------+
| source_code | qty | is_salable |
+-------------+------+-----------+
| default | 100 | 1 |
| warehouse1 | 50 | 1 |
| warehouse2 | 25 | 1 |
+-------------+------+-----------+
Stock Data Configuration
// Set stock data
$product->setStockData([
'use_config_manage_stock' => 1,
'qty' => 100,
'is_in_stock' => 1, // 1=in stock, 0=out of stock
'manage_stock' => 1, // 1=manage stock, 0=don't track
'use_config_notify_stock_qty' => 1,
'notify_stock_qty' => 5, // Low stock threshold
'backorders' => 0, // 0=no backorders
'min_qty' => 0, // Minimum qty for order
'min_sale_qty' => 1, // Minimum sale qty
'max_sale_qty' => 0, // Maximum sale qty (0=unlimited)
'is_qty_decimal' => 0, // 1=allow decimal qty
'stock_status_changed_auto' => 0,
]);
// Update stock
$stockData = $product->getStockData();
$stockData['qty'] = 75;
$stockData['is_in_stock'] = 1;
$product->setStockData($stockData);
$product->save();
Inventory Check
// Check if product is in stock
$stockState = $objectManager->get(
\Magento\CatalogInventory\Api\StockStateInterface::class
);
$qty = $stockState->getStockQty($product->getId());
$isSalable = $stockState->verifyStock($product->getId());
// Check specific source
$sourceItems = $objectManager->get(
\Magento\InventoryApi\Api\GetSourceItemsBySkuInterface::class
);
$items = $sourceItems->execute($product->getSku());
Pricing and Associations
Pricing Structure
// Base price
$product->setPrice(29.99);
// Special price (discounted)
$product->setSpecialPrice(24.99);
$product->setSpecialFromDate('2024-01-01');
$product->setSpecialToDate('2024-12-31');
// Tier pricing (quantity discounts)
$tierPrice = [
'website_id' => 0,
'cust_group' => 1, // General group
'price_qty' => 10,
'price' => 25.00,
];
// Group price
$groupPrice = [
'cust_group' => 1,
'price' => 27.00,
];
Product Associations
// Up-sells
$product->setUpsellProductIds([10, 11, 12]);
// Cross-sells
$product->setCrosssellProductIds([20, 21, 22]);
// Related products
$product->setRelatedProductIds([30, 31, 32]);
// Grouped product association
$groupedProduct->setAssociatedProductIds([1, 2, 3]);
Product Relations Table
-- catalog_product_link
SELECT * FROM catalog_product_link
WHERE link_type_id = 1 AND product_id = 123;
+----------+------------+---------------+
| link_id | product_id | linked_product_id | link_type_id |
+----------+------------+---------------+
| 456 | 123 | 10 | 1 |
| 457 | 123 | 11 | 1 |
| 458 | 123 | 12 | 1 |
+----------+------------+---------------+
-- Link types:
-- 1 = Up-sell
-- 2 = Cross-sell
-- 3 = Related
-- 4 = Grouped
Best Practices
1. Use meaningful SKUs (TSHIRT-BLUE-L)
2. Manage inventory for each simple product
3. Set appropriate visibility
4. Configure tax classes correctly
5. Use tier pricing for bulk discounts
6. Link related products for better UX
Quiz
1. What is a simple product?
2. What does visibility control?
3. What link type represents up-sells?
Flashcards
Question
What is a simple product?
Click to reveal answer
Answer
Standalone physical item with single SKU, no variants
Question
What does visibility control?
Click to reveal answer
Answer
Where product appears: catalog (2), search (3), both (4), not visible (1)
Question
How to set stock data?
Click to reveal answer
Answer
Product->setStockData(['qty' => 100, 'is_in_stock' => 1])
Question
What are the link types?
Click to reveal answer
Answer
1=Up-sell, 2=Cross-sell, 3=Related, 4=Grouped
Question
What is special price?
Click to reveal answer
Answer
Discounted price with from/to date range
Revision Notes
Key Takeaways
- 1. Simple products are standalone items with single SKU
- 2. SKU must be unique across all products
- 3. Inventory managed via stock data (qty, is_in_stock, manage_stock)
- 4. Pricing: base price, special price, tier price, group price
- 5. Associations: up-sells, cross-sells, related products
Interview Tips
- • Explain simple product structure and properties
- • Discuss SKU management and validation
- • Describe inventory and pricing configuration
Cheat Sheet
Simple Product:
type_id = 'simple'
Single SKU, standalone item
Key Attributes:
sku, name, price, special_price
status (1=enabled, 2=disabled)
visibility (1-4)
tax_class_id
weight
Stock Data:
qty, is_in_stock, manage_stock
min_sale_qty, max_sale_qty
backorders, notify_stock_qty
Pricing:
price, special_price (with dates)
tier_price (quantity discounts)
group_price (customer group)
Associations:
upsell, crosssell, related