Skip to main content
Share Your Experience: Take the 2024 Developer Survey
10 votes
Accepted

Create a bundle product programmatically - Magento 2

You code should like: /** @var $objectManager \Magento\TestFramework\ObjectManager */ $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // instance of object manager /** @var \...
KAndy's user avatar
  • 20.9k
7 votes

How to get the price range of bundle products in Magento 2?

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $product = $objectManager->get('Magento\Catalog\Model\Product')->load(YOUR_ID); $bundleObj=$product->getPriceInfo()->...
Keyur Shah's user avatar
  • 18.1k
7 votes

which observer to call while removing item from cart and empty cart?

Besides the controller pre|post dispatch events that don't do you much good, though you can still use them controller_action_predispatch_checkout_cart_delete and ...
Marius's user avatar
  • 198k
7 votes
Accepted

Magento2 Change bundle item price in cart

So finally I was able to achieve this, first we need a events.xml For my requirement I needed this event observer for both frontend and adminhtml so the events.xml was create at app/code/Foo/...
Atish Goswami's user avatar
6 votes
Accepted

How to override a block without name?

You can use setChild() to replace a block by its alias. First create the new block with a name, then call setChild() via <action>: <referenceBlock name="order_items"> <block class="...
Fabian Schmengler's user avatar
5 votes

Disallow sell of a simple product but allow that product to be sell in bundled product

Just simple solution for that Just Set that simple Product visibility to Not Visible Individually Hope this will help you and let me know if its not working
Murtuza Zabuawala's user avatar
5 votes

Magento 2.1: <preference> doesn't work with block

To replace a single method, use the around plugin and don't call the original method with $proceed()
Fabian Schmengler's user avatar
5 votes
Accepted

Magento 2.1: <preference> doesn't work with block

Thanks fschmengler , I managed to solve this by using Plugin. Override/replace single method in block class: app/code/MySpace/MyModule/etc/di.xml <config xmlns:xsi="http://www.w3.org/2001/...
pekkaliu's user avatar
  • 181
4 votes
Accepted

Bundled product remove "Price as configured"

If you will activate the "Template path hints" you will see that the template responsible for rendering this price is template/bundle/catalog/product/view/price.phtml. Now, if you go into bundle.xml ...
Alex Constantinescu's user avatar
4 votes
Accepted

Display old price in dynamic bundle product price

Sorry for the late response but I just faced this myself and solved it as follows... In bundle/catalog/product/price.phtml (Not bundle/catalog/product/view/price.phtml) find the block of code that ...
Steve Gardner's user avatar
4 votes

How to get the price range of bundle products in Magento 2?

Just to add to this answer for getting the min/max price, if you want it to display with currency formatted you need the raw number value. The accepted answer returns an object rather than a flat ...
pixiemedia's user avatar
4 votes
Accepted

Magento 2 - Losing data with extension attributes in bundle options collection

The documentation for extension attributes is not quite clear on what's the right way to use them and it seems like each entity type does it in a slightly different way. That being said, from my ...
Fabian Schmengler's user avatar
4 votes
Accepted

How to get object value?

If $amount is this object, use: $amount->getValue(); How to find out by yourself: Look at the source code of Magento\Framework\Pricing\Amount\Base and search for $this->amount. If you find a ...
Fabian Schmengler's user avatar
4 votes
Accepted

Magento 1.9 Get only default items from options of a bundle product

You can do this: $product = Mage::getModel('catalog/product')->load(bundle_pruduct_id); $selectionCollection = $product->getTypeInstance(true)->getSelectionsCollection( $product->...
olkuznw's user avatar
  • 146
3 votes

Magento products packs (assortiment) with size and stock control - like 3-pack or 6-pack

You could create the "6 pack" product as a bundle with one required dropdown option, call it "size". Add the S, M and L simple products as selections for this option with a default qty of 6 and "...
Fabian Schmengler's user avatar
3 votes
Accepted

Limit cart quantity of bundled product

The core feature "Maximum qty" is tied to stock items, so it does not work with bundles (they don't have their own stock). You have to develop it on your own. For simple products, the check happens ...
Fabian Schmengler's user avatar
3 votes

Magento 2 Add Bundled Product to Cart Programmatically

Below you can find my code to how i resolve it, you have to use field selection_id and not sub product id (in this case i use only one multiselect option): // get selection option in a bundle ...
elachino's user avatar
3 votes
Accepted

Magento 2 Add Bundled Product to Cart Programmatically

I reckon the right way of doing it would be the following: First you need to inject the following classes to your class constructor: protected $_cart; protected $_productRepository; public ...
Raphael at Digital Pianism's user avatar
3 votes
Accepted

Bundled product pricing/configuration confusion

As per my above scenario, I haven't got the main product listed as a bundled item/associated product within the bundled product, it is in fact the actual product that I converted to a bundled product.....
Fabian Schmengler's user avatar
3 votes

Create a bundle product programmatically - Magento 2

Magento2 programmatically adding a custom option I propose to look at this post - which provides much easier answer and first of all working one. Look at /dev/tests/integration/testsuite/Magento/...
Bartosz Kubicki's user avatar
3 votes

Programmatically create an order of grouped and bundle product in Magento

Don't use Mage_Sales_Model_Quote::addProduct(), especially for complex products. Use Mage_Checkout_Model_Cart::addProduct() which is also used by the add to cart controller action and takes care for ...
Fabian Schmengler's user avatar
3 votes
Accepted

How to get selected bundle items price

You will find selected bundle items data at the time of add to cart, like below : $options = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct()); :)
Krupali's user avatar
  • 1,140
3 votes
Accepted

Magento 2 - How to remove the price of each bundle product option in the shopping cart, order confirmation, review your cart page, etc

In alignment with what @tjons pointed out, in my di.xml for the module I created I needed to add a new entry to list the preference to pick up my Configuration.php file over the core one. After that I ...
Noemi Quezada's user avatar
3 votes

How to load bundle child product by parent product ID?

You can get the type instance in your bundle product, then get the children IDs, as below. $typeInstance = $product->getTypeInstance(); $requiredChildrenIds = $typeInstance->getChildrenIds($...
Ajeet Singh's user avatar
3 votes

How to get bundle product items options html in magento 2.3 programmatically?

Please check with below code : $store_id = $_storeManager->getStore()->getId();            $options = $_objectManager->get('Magento\Bundle\Model\Option')         ->...
Anas Mansuri's user avatar
  • 2,627
3 votes
Accepted

How to get bundle product price by product id ? Magento2

Please try this: $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $product = $objectManager->create('Magento\Catalog\Model\Product')->load($product_id); if ($product->...
temper's user avatar
  • 994
3 votes
Accepted

How to add a label to simple & Bundle product price?

For Simple /vendor/magento/module-catalog/view/base/templates/product/price/final_price.phtml override on below path /app/design/frontend/theme/Magento_Catalog/templates/product/price/final_price....
Gohil Rajesh's user avatar
  • 2,947
2 votes

Magento Bundle Product Price Different in Product View Page and Search Result Page

Based on what you have said, this looks like the search indexes need to be re-indexed. This can be done either through the admin panel under System > Index Management or on the command line with ...
Galahad Longshadow's user avatar
2 votes
Accepted

allowing product with custom options as bundled item

This cannot be done out of the box. I found following two extension. That seams to let you build a bundle items with custom options. https://www.magentocommerce.com/magento-connect/dependent-custom-...
Rohit Kundale's user avatar
2 votes

What is the suggested value of max_execution_time and memory_limit for 20,000 products site for Bulk export

It depends on so many factors. A production server setting of 300 seconds is ideal, but that depends on the setup. In any case, PHP execution should not exceed 600 (seconds), in general (as mentioned ...
Mohit Kumar Arora's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible