I want to set custom price to bundle product. especially apply to the main product, not its options product. I need to apply the discount on the bundle's total price.

Here is my code working for the normal product type. it's properly working.

     * @param type $item
     * @return true
    protected function setItemPrice($item, $price) {

Here you can apply price to bundle product programmatically.

$product = $objectManager->create(\Magento\Catalog\Api\Data\ProductInterface::class);

$product->setSku('bundle-csec'); // Set your sku here       
$product->setName("Bundle Csec"); // Name of Product
$product->setStatus(1); // Status on product enabled/ disabled 1/0
$product->setWeight('75'); // weight of product
$product->setVisibility(4); // visibilty of product (catalog / search / catalog, search / Not visible individually)
**$product->setPrice('75');** // price of product
$product->setCustomAttribute('description', "Here is your prod description");

Let me know if that worked for you.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.