2

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) {
        $item->getProduct()->setSpecialPrice($price);
        $item->setCustomPrice($price);
        $item->setOriginalCustomPrice($price);
        $item->getProduct()->setIsSuperMode(true);
    }       

1 Answer 1

0

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->setAttributeSetId(4);
$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->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE);
**$product->setPrice('75');** // price of product
$product->setPriceView(0);
$product->setCustomAttribute('description', "Here is your prod description");

Let me know if that worked for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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