Skip to main content
26 votes

Getting simple products from configurable

The answers to this question are wrong. Although their implementations might work, it's not the proper way to handle this. The correct way to do this is by using Magentos' service contracts and data ...
Giel Berkers's user avatar
  • 12.3k
15 votes
Accepted

how to get product thumbnail and product url in order confirmation email

you have to load product to get thumbnail and url . <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $product = $objectManager->create('Magento\Catalog\Model\...
Qaisar Satti's user avatar
  • 32.5k
8 votes
Accepted

Magento 2 - Set simple product Color when creating product programmatically

$attr = $_product->getResource()->getAttribute('color'); $avid = $attr->getSource()->getOptionId('Blue'); //name in Default Store View $_product->setData('color', $avid); I found the answer from here ...
user3748173's user avatar
8 votes
Accepted

Disadvantages for virtual product?

There is no major disadvantage of that. But main concept is if product has a weight then you need to deliver it physically. If product has no weight that means its virtual product (Something which ...
Manthan Dave's user avatar
  • 9,856
8 votes
Accepted

Magento2 - How to see if configurable products has simple products attached

Try below script from magento2 root: <?php error_reporting(E_ALL); ini_set('display_errors', 1); use Magento\Framework\App\Bootstrap; try{ require __DIR__ . '/app/bootstrap.php'; $...
Pratik Oza's user avatar
  • 3,992
8 votes
Accepted

Stop simple product images overriding main product gallery after clicking swatches

By adding the following code to the theme's view.xml the image from the simple product is now added to the product gallery rather than replacing the one associated with the configurable product. <...
SilkSpin's user avatar
  • 302
7 votes
Accepted

Magento 2.3 Saleable stock qty does not equal Global Attribute Qty

Check inventory_reservation: https://github.com/magento-engcom/msi/wiki/Salable-Quantity-Calculation-and-Mechanism-of-Reservations If you don't want to use MSI (and stick to CatalogInventory_* from 2....
dudzio's user avatar
  • 620
6 votes

how to check if a product is a simple product and not a child of a configurable product

Simply I did: (Magento 1.8) if($_product->isConfigurable()) { echo 'config'; }
Sumith Harshan's user avatar
6 votes
Accepted

How to add simple product to cart instead of configurable product in Magento2

So, this is my solution: class Cart { protected $quote; protected $request; protected $configurableproduct; protected $urlinterface; protected $productrepository; public function __construct( \...
ps202's user avatar
  • 160
6 votes
Accepted

Get collection of simple simple products in Magento2

This should do the trick public function getProducts() { /** @var $collection \Magento\Catalog\Model\ResourceModel\Product\Collection */ $collection = $this->_productCollectionFactory->...
Shawn Abramson's user avatar
5 votes

Get Custom Option Values of a product magento 2

Try this: $_product = $block->getProduct(); foreach ($_product->getOptions() as $o) { if ($o->getTitle() != 'Color') { // or another title of option continue; } foreach ($...
Siarhey Uchukhlebau'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

How to get Customizable Options of a simple product in magento 2

First of: don't directly use the Object Manager, but use dependency injection instead. Secondly, for this task you have a Service Contract that's specific for this purpose: the \Magento\Catalog\Api\...
Giel Berkers's user avatar
  • 12.3k
5 votes
Accepted

How to get Customizable Options of a simple product in magento 2

Got the correct answer.. In your phtml page, $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $product = $objectManager->get('Magento\Framework\Registry')->registry('...
Rita Jose's user avatar
  • 1,850
4 votes
Accepted

Best way to assign simple product to configurable

I rembember that there was a module on a client's installation to convert the type of products but it was not really bugproof. If you mean to convert each product into configurable, you will most ...
Christophe Ferreboeuf's user avatar
4 votes
Accepted

How to correctly update product programmatically - Magento 2

After debugging the code and using the suggestion of @David i realized that the problem wasn't the way i used to create products attributes but the i was using the Create method of the Object Manager (...
A. Martz's user avatar
  • 305
4 votes

How to assign simple product images to configurable product in magento 1

Assuming, that the loaded simple product does hold an image you can do it like so (see addImageToMediaGallery()): <?php require_once('app/Mage.php'); umask(0); Mage::app('default'); Mage::app()-&...
Christoph Farnleitner's user avatar
4 votes

Added a product as configurable but is is showing as simple? Can I change it?

The product is Configurable only if it has children, otherwise, it is "converted" into a Simple product. vendor/magento/module-configurable-product/Model/Product/TypeTransitionManager/Plugin/...
Pratik Oza's user avatar
  • 3,992
4 votes

Magento2 which table to store data like configurable product

Main table for products in magento: catalog_product_entity Above table is an act as main table, for that child tables are staring with “catalog_product_entity_” prefix. - ...
Rakesh Donga's user avatar
  • 5,364
4 votes
Accepted

How the Magento 2 Final price calculate for the simple product?

So again you have: Regular price -> 100 Catalog price rule -> 10% Special price -> 80 Tier price when a customer buys 1 item -> 70 (keep in mind that this price is lower than Special price) Tier ...
underser's user avatar
  • 550
3 votes

When child product visibility is set to 'Not visible individually' don't redirect to 404

This is not an answer to your question, but it may be a solution to your problem. If you want the simple products to be accessible, you can just set their visibility to Catalog and don't assign them ...
Marius's user avatar
  • 198k
3 votes

Get Custom Option Values of a product magento 2

$customOptions = $objectManager->get('Magento\Catalog\Model\Product\Option')->getProductOptionCollection($_product); foreach($customOptions as $optionKey => $optionVal): ...
Charvi Parikh's user avatar
3 votes

Getting simple products from configurable

You can just call below method, foreach($collection as $_product) { $_configChild = $_product->getTypeInstance()->getUsedProductIds($_product); $getChildId = array()...
Rakesh Jesadiya's user avatar
3 votes

Magento Configurable Product Price Overriding Simple Product Price

Kindly follow the below steps to change the super attribute price First Use observers "catalog_product_get_final_price". Make observers like this : Open your module config.xml and use below code : &...
Chandresh Rana's user avatar
3 votes

How to add simple product to cart instead of configurable product

Despite this being an almost 3-year-old question, I figured I'd add my own answer since I was trying to do this myself and hopefully someone will find my solution useful. All I did was add a plugin ...
Joseph G-H's user avatar
3 votes

Magento2 get variants of configurable products

You can get child product of current configurable product by this simple code: $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $product = $objectManager->get('Magento\...
Prince Patel's user avatar
  • 22.8k
3 votes
Accepted

Magento 2: Set backorder status programmatically

To set backorder status programmatically you need to override /module-catalog/Controller/Adminhtml/Product/Save.php and do this: $stockData = ['backorders' => 0, '...
Fred August's user avatar
3 votes
Accepted

change visibility of all simple product

Mysql: Magento save the relation between configurable product and it child products at catalog_product_super_link and save it product basic data at catalog_product_entity Table. Write select query ...
Amit Bera's user avatar
  • 77.6k
3 votes

Add text within block via xml

This would add your static text block above the price. <referenceContainer name="product.info.main"> <block class="Magento\Framework\View\Element\Text" name="your.block.name" before="...
Rendy Eko Prastiyo's user avatar

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