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 ...
17
votes
Accepted
Magento2 get variants of configurable products
Try with $product->getTypeInstance()->getUsedProducts($product).
14
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\...
9
votes
Accepted
Magento2 Create simple Product programmatically only works once
Injecting Magento\Catalog\Model\Product in the constructor means, you get the same instance every time (like a singleton).
That does not make sense for models. Instead you should inject Magento\...
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 ...
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 ...
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';
$...
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.
<...
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....
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';
}
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(
\...
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->...
5
votes
Magento Configurable Product Price Overriding Simple Product Price
Using Magento Version 1.9.2.2
May be slightly better solution, use 'Observer' approach instead of hacking the core or even overriding the default Model Price class i.e. app/code/core/Mage/Catalog/...
5
votes
Accepted
How can I stop other attributes changing my swatch image?
Facing with the same problem, today I wrote the following fix, it works both with attribute selectors and configurable swatches.
$j(document).ready(function() {
if (typeof ConfigurableMediaImages ...
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 ($...
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
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\...
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('...
4
votes
Magento 2 : New Configurable product - selecting existing simple products manually?
There is currently an open issue on github.
Interestingly there seems to be other closed issues around this. At the moment i am not sure it is getting elevated to any degree. Maybe because people are ...
4
votes
Accepted
How redirect simple products of Configurable product
the code below should work only if the simple products are assigned to only one configurable product.
by default, magento allows you to add a simple product to as many configurable products you need. ...
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 ...
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 (...
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()-&...
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/...
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.
- ...
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 ...
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\...
3
votes
Filtering status on simple products
In this instead of using Mage::getModel('catalog/product_type_configurable') and getting child product color option.
You can use product collection resource model Mage::getResourceModel('catalog/...
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 :
&...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
simple-product × 324configurable-product × 200
magento2 × 83
magento-1.9 × 65
product × 35
price × 20
custom-options × 19
product-attribute × 18
grouped-products × 17
magento-2.1 × 16
attributes × 15
cart × 14
magento-1.8 × 13
bundled-product × 11
magento2.3 × 9
magento-1.7 × 9
virtual-products × 9
php × 8
import × 8
catalog × 8
sku × 8
associate-products × 8
addtocart × 7
products × 7
programmatically × 7