How to set Sku Type & Price Type of Bundle Product programmatically in Magento?

How to set Sku Type & Price Type of Bundle Product programmatically in Magento?

September 9, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to set Sku Type & Price Type of Bundle Product programmatically in Magento?

Setting Sku Type & Price Type of Bundle Product Programmatically in Magento

As a senior developer and technical blogger, I understand the frustration you’re experiencing when a programmatically added bundle product fails to display on the frontend despite appearing correctly in the admin section. Let’s dive into this issue and provide a comprehensive solution.

Debugging the Frontend Display Issue

When a bundle product doesn’t show up on the frontend, there could be several reasons behind it. Here are some steps we can take to debug this:

  1. Check your Magento cache: Ensure that you’ve cleared all caches (including Redis or Memcached if enabled) after adding the new bundle product programmatically.

  2. Inspect the product in the admin section: Verify that the ‘Visibility’ attribute of the bundle product is set to either ‘Catalog, Search’ or a specific category where it should appear on the frontend. A visibility setting of ‘Not Visible Individually’ may prevent the bundle from showing up alone.

  3. Check for any custom logic in your theme: If you have custom theme files overriding the catalog_product_view template, there might be some code preventing the bundle product from displaying.

  4. Inspect the database records: Ensure that the bundle product’s record is present in the catalog_product_entity table and all its related tables (catalog_product_entity_int, catalog_product_entity_varchar, etc.). Look for any null or incorrect values, especially in the visibility column.

Setting Special Properties of Bundle Product Programmatically

Now let’s address your requirement to control the special properties of a bundle product during programmatic insertion. These properties include sku_type, weight_type, shipment_type, price_view, and price_type.

To set these values, you can utilize the following methods provided by the Mage_Catalog_Model_Product_Type_Bundle class:

  • $bundle->setSkuType($value): Sets the SKU type for the bundle product. The possible values are simple, configurable, or a custom SKU type.
  • $bundle->setWeightType($value): Sets the weight type for the bundle product. The possible values are fixed or dynamic.
  • $bundle->setShipmentType($value): Sets the shipment type for the bundle product. The possible values are single, separate, or a custom shipment type.
  • $bundle->setPriceView($value): Sets the price view mode for the bundle product. The possible values are fixed (fixed pricing for each selection) or as-low-as (price based on the lowest-priced option).
  • $bundle->setPriceType($value): Sets the price type for the bundle product. The possible values are fixed, dynamic, or a custom price type.

Here’s an example code snippet demonstrating how to set these properties during the programmatic insertion of a bundle product:

$bundle = Mage::getModel('catalog/product');
$bundle->setSku('BUNDLE-SKU-01')
      ->setName('Sample Bundle Product')
      ->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
      ->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_BUNDLE);

$bundle->setSkuType('simple'); // Set SKU type
$bundle->setWeightType('fixed'); // Set weight type
$bundle->setShipmentType('single'); // Set shipment type
$bundle->setPriceView('as-low-as'); // Set price view mode
$bundle->setPriceType('dynamic'); // Set price type

// Add bundle options and selections here using setBundleOptionsData() and setBundleSelectionsData()

try {
    $bundle->save();
    Mage::getSingleton('catalog/product_status')->updateProductStatus(array($productId => 2), false);
} catch (Exception $e) {
    // Handle the exception
}

Remember to replace $productId with the actual ID of your bundle product.

Conclusion

To summarize, when a programmatically added bundle product fails to display on the frontend, you should first ensure that the cache is cleared and verify the visibility settings in the admin section. Additionally, inspect the database records for any inconsistencies or null values.

When setting special properties like sku_type and price_type, utilize the methods provided by the Mage_Catalog_Model_Product_Type_Bundle class during the programmatic insertion of a bundle product.

If you’re still facing issues or need further assistance, feel free to reach out. I’m always available to provide expert guidance on Magento development and programming issues.

Happy coding!

Catalog Cache Database Themes

Our network