How to add products programmatically

$post_id = 3537;
$module_id = 'Offer';

$products = [
    [
        'unique_id' => 'prod001',
        'title' => 'Wireless Headphones',
        'subtitle' => 'Crystal-clear sound with deep bass',
        'description' => 'High-quality wireless headphones with noise cancellation.',
        'img' => 'https://example.com/images/headphones.jpg',
        'url' => 'https://example.com/products/headphones',
        'orig_url' => 'https://example.com/products/headphones',
        'price' => 99.99,
        'priceOld' => 149.99,
        'currencyCode' => 'USD',
        'merchant' => 'ExampleStore',
        'badge' => 'Best Seller',
        'badge_color' => 'primary',
        'logo' => 'https://example.com/logos/examplestore.png',
        'ratingDecimal' => 4.5,
        'order' => '',
        'stock_status' => 1,
    ],
    [
        'unique_id' => 'prod002',
        'title' => 'Smart Watch',
        'subtitle' => 'Track your fitness in style',
        'description' => 'Fitness-focused smartwatch with heart rate monitor and GPS.',
        'img' => 'https://example.com/images/smartwatch.jpg',
        'url' => 'https://example.com/products/smartwatch',
        'orig_url' => 'https://example.com/products/smartwatch',
        'price' => 129.99,
        'priceOld' => 179.99,
        'currencyCode' => 'USD',
        'merchant' => 'TimeTech',
        'badge' => 'Hot Deal',
        'badge_color' => 'primary',
        'logo' => 'https://example.com/logos/timetech.png',
        'ratingDecimal' => 5,
        'order' => '',
        'stock_status' => 1,
    ],
    [
        'unique_id' => 'prod003',
        'title' => 'Bluetooth Speaker',
        'subtitle' => 'Powerful sound in your palm',
        'description' => 'Portable Bluetooth speaker with deep bass and waterproof design.',
        'img' => 'https://example.com/images/speaker.jpg',
        'url' => 'https://example.com/products/speaker',
        'orig_url' => 'https://example.com/products/speaker',
        'price' => 49.99,
        'priceOld' => 69.99,
        'currencyCode' => 'USD',
        'merchant' => 'SoundPro',
        'badge' => 'Editor\'s Pick',
        'badge_color' => 'primary',
        'logo' => 'https://example.com/logos/soundpro.png',
        'ratingDecimal' => 4.7,
        'order' => '',
        'stock_status' => 1,
    ],
];

\ContentEgg\application\components\ContentManager::saveData($products, $module_id, $post_id);

Last updated