Need to show related products of simple product in configurable productProgramatically add simple to configurable productsShow configurable products on product info pageConfigurable items in related and upsell areasProduct collection shows out of stock configurable productsHow do I add a configurable as a related product and show it's options in Magento 2.1Simple products with customizable options needs to be shown in configurable product Magento 2Related product does not show when selecting product from configurable productGet Configurable Product options, Price And Add to cart Button On Related Product SectionGet configurable products associated with simple productsHow to show configurable product as related product with their options in Magento
...and then she held the gun
How can I prevent a user from copying files on another hard drive?
Is this broken pipe the reason my freezer is not working? Can it be fixed?
Why do you need to heat the pan before heating the olive oil?
Justifying Affordable Bespoke Spaceships
Bash function: Execute $@ command with each argument in sequence executed separately
What is this plant I saw for sale at a Romanian farmer's market?
Time travel short story where someone from the past follows the travelers back
How to address players struggling with simple controls?
Weird thing in 737 cabin
how to find which software is doing ssh connection?
My student in one course asks for paid tutoring in another course. Appropriate?
Is this a valid proof that A = B given A ∩ B = A ∪ B?
Explicit song lyrics checker
Do details of my undergraduate title matter?
How to make a villain when your PCs are villains?
Is using Legacy mode is a bad thing to do?
How can caller ID be faked?
What does this Swiss black on yellow rectangular traffic sign with a symbol looking like a dart mean?
How can the US president give an order to a civilian?
Automatically open a terminal window and run a command, robustly
What does "vrit' mean with reference to documentaries?
You may find me... puzzling
How is linear momentum conserved in circular motion?
Need to show related products of simple product in configurable product
Programatically add simple to configurable productsShow configurable products on product info pageConfigurable items in related and upsell areasProduct collection shows out of stock configurable productsHow do I add a configurable as a related product and show it's options in Magento 2.1Simple products with customizable options needs to be shown in configurable product Magento 2Related product does not show when selecting product from configurable productGet Configurable Product options, Price And Add to cart Button On Related Product SectionGet configurable products associated with simple productsHow to show configurable product as related product with their options in Magento
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I need to show related products block on configurable product page (as it is by deflault), but instead of related products of configurable product i need to show related products of simple products which are included in that configurable product.
magento2 configurable-product blocks related-products
add a comment |
I need to show related products block on configurable product page (as it is by deflault), but instead of related products of configurable product i need to show related products of simple products which are included in that configurable product.
magento2 configurable-product blocks related-products
ok but you can display only the products under configurable products that are visible and in stock with inventory will show. what you want here ?
– Charul Tyagi
Sep 10 '18 at 10:40
i need that when i select simple product for any configurable product that simple product related product data should also be shown as related product in configurable product
– Arjun
Sep 10 '18 at 11:01
so if you select any simple product it should be visibility should be catalog,search to front-end ,in stock and have inventory too then can list down in related products
– Charul Tyagi
Sep 10 '18 at 11:22
Ok let me recorrect myself when i redirect to any configurable product page i need to see related products on that page but that related products should not be of that configurable product but of all the simple products attach to that configurable product
– Arjun
Sep 10 '18 at 12:25
add a comment |
I need to show related products block on configurable product page (as it is by deflault), but instead of related products of configurable product i need to show related products of simple products which are included in that configurable product.
magento2 configurable-product blocks related-products
I need to show related products block on configurable product page (as it is by deflault), but instead of related products of configurable product i need to show related products of simple products which are included in that configurable product.
magento2 configurable-product blocks related-products
magento2 configurable-product blocks related-products
edited Jun 10 at 10:20
Shan Atif
15814
15814
asked Sep 10 '18 at 6:29
ArjunArjun
1,969926
1,969926
ok but you can display only the products under configurable products that are visible and in stock with inventory will show. what you want here ?
– Charul Tyagi
Sep 10 '18 at 10:40
i need that when i select simple product for any configurable product that simple product related product data should also be shown as related product in configurable product
– Arjun
Sep 10 '18 at 11:01
so if you select any simple product it should be visibility should be catalog,search to front-end ,in stock and have inventory too then can list down in related products
– Charul Tyagi
Sep 10 '18 at 11:22
Ok let me recorrect myself when i redirect to any configurable product page i need to see related products on that page but that related products should not be of that configurable product but of all the simple products attach to that configurable product
– Arjun
Sep 10 '18 at 12:25
add a comment |
ok but you can display only the products under configurable products that are visible and in stock with inventory will show. what you want here ?
– Charul Tyagi
Sep 10 '18 at 10:40
i need that when i select simple product for any configurable product that simple product related product data should also be shown as related product in configurable product
– Arjun
Sep 10 '18 at 11:01
so if you select any simple product it should be visibility should be catalog,search to front-end ,in stock and have inventory too then can list down in related products
– Charul Tyagi
Sep 10 '18 at 11:22
Ok let me recorrect myself when i redirect to any configurable product page i need to see related products on that page but that related products should not be of that configurable product but of all the simple products attach to that configurable product
– Arjun
Sep 10 '18 at 12:25
ok but you can display only the products under configurable products that are visible and in stock with inventory will show. what you want here ?
– Charul Tyagi
Sep 10 '18 at 10:40
ok but you can display only the products under configurable products that are visible and in stock with inventory will show. what you want here ?
– Charul Tyagi
Sep 10 '18 at 10:40
i need that when i select simple product for any configurable product that simple product related product data should also be shown as related product in configurable product
– Arjun
Sep 10 '18 at 11:01
i need that when i select simple product for any configurable product that simple product related product data should also be shown as related product in configurable product
– Arjun
Sep 10 '18 at 11:01
so if you select any simple product it should be visibility should be catalog,search to front-end ,in stock and have inventory too then can list down in related products
– Charul Tyagi
Sep 10 '18 at 11:22
so if you select any simple product it should be visibility should be catalog,search to front-end ,in stock and have inventory too then can list down in related products
– Charul Tyagi
Sep 10 '18 at 11:22
Ok let me recorrect myself when i redirect to any configurable product page i need to see related products on that page but that related products should not be of that configurable product but of all the simple products attach to that configurable product
– Arjun
Sep 10 '18 at 12:25
Ok let me recorrect myself when i redirect to any configurable product page i need to see related products on that page but that related products should not be of that configurable product but of all the simple products attach to that configurable product
– Arjun
Sep 10 '18 at 12:25
add a comment |
1 Answer
1
active
oldest
votes
If you want to display related products of child items instead of the related products of the parent item in a configurable product structure, then
Create a new module and override _prepareData
function the main block file
vendor/magento/module-catalog/Block/Product/ProductList/Related.php
Something like
protected function _prepareData()
$product = $this->_coreRegistry->registry('product');
/* @var $product MagentoCatalogModelProduct */
// GET TYPE
$productType = $product->getTypeId();
// IF CONFIGURABLE
if ($productType == 'configurable')
$childrenProducts = $product->getTypeInstance()->getUsedProducts($product);
if ($childrenProducts)
$this->_itemCollection = array();
foreach ($childrenProducts as $singleChild)
$relatedProductCollection = $singleChild->getRelatedProductCollection()->addAttributeToSelect(
'required_options'
)->setPositionOrder()->addStoreFilter();
if ($this->moduleManager->isEnabled('Magento_Checkout'))
$this->_addProductAttributesAndPrices($relatedProductCollection);
$relatedProductCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
$relatedProductCollection->load();
foreach ($relatedProductCollection as $singleProduct)
$singleProduct->setDoNotUseCategoryId(true);
$this->_itemCollection[] = $singleProduct;
else
// IF OTHERS
// main FUNCITON CODE
return $this;
and then override the items.phtml
file
vendor/magento/module-catalog/view/frontend/templates/product/list/items.phtml
under case 'related'
change the if condition
if ($exist = $block->getItems()->getSize())
to
if ($exist = count($block->getItems()))
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f241496%2fneed-to-show-related-products-of-simple-product-in-configurable-product%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you want to display related products of child items instead of the related products of the parent item in a configurable product structure, then
Create a new module and override _prepareData
function the main block file
vendor/magento/module-catalog/Block/Product/ProductList/Related.php
Something like
protected function _prepareData()
$product = $this->_coreRegistry->registry('product');
/* @var $product MagentoCatalogModelProduct */
// GET TYPE
$productType = $product->getTypeId();
// IF CONFIGURABLE
if ($productType == 'configurable')
$childrenProducts = $product->getTypeInstance()->getUsedProducts($product);
if ($childrenProducts)
$this->_itemCollection = array();
foreach ($childrenProducts as $singleChild)
$relatedProductCollection = $singleChild->getRelatedProductCollection()->addAttributeToSelect(
'required_options'
)->setPositionOrder()->addStoreFilter();
if ($this->moduleManager->isEnabled('Magento_Checkout'))
$this->_addProductAttributesAndPrices($relatedProductCollection);
$relatedProductCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
$relatedProductCollection->load();
foreach ($relatedProductCollection as $singleProduct)
$singleProduct->setDoNotUseCategoryId(true);
$this->_itemCollection[] = $singleProduct;
else
// IF OTHERS
// main FUNCITON CODE
return $this;
and then override the items.phtml
file
vendor/magento/module-catalog/view/frontend/templates/product/list/items.phtml
under case 'related'
change the if condition
if ($exist = $block->getItems()->getSize())
to
if ($exist = count($block->getItems()))
add a comment |
If you want to display related products of child items instead of the related products of the parent item in a configurable product structure, then
Create a new module and override _prepareData
function the main block file
vendor/magento/module-catalog/Block/Product/ProductList/Related.php
Something like
protected function _prepareData()
$product = $this->_coreRegistry->registry('product');
/* @var $product MagentoCatalogModelProduct */
// GET TYPE
$productType = $product->getTypeId();
// IF CONFIGURABLE
if ($productType == 'configurable')
$childrenProducts = $product->getTypeInstance()->getUsedProducts($product);
if ($childrenProducts)
$this->_itemCollection = array();
foreach ($childrenProducts as $singleChild)
$relatedProductCollection = $singleChild->getRelatedProductCollection()->addAttributeToSelect(
'required_options'
)->setPositionOrder()->addStoreFilter();
if ($this->moduleManager->isEnabled('Magento_Checkout'))
$this->_addProductAttributesAndPrices($relatedProductCollection);
$relatedProductCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
$relatedProductCollection->load();
foreach ($relatedProductCollection as $singleProduct)
$singleProduct->setDoNotUseCategoryId(true);
$this->_itemCollection[] = $singleProduct;
else
// IF OTHERS
// main FUNCITON CODE
return $this;
and then override the items.phtml
file
vendor/magento/module-catalog/view/frontend/templates/product/list/items.phtml
under case 'related'
change the if condition
if ($exist = $block->getItems()->getSize())
to
if ($exist = count($block->getItems()))
add a comment |
If you want to display related products of child items instead of the related products of the parent item in a configurable product structure, then
Create a new module and override _prepareData
function the main block file
vendor/magento/module-catalog/Block/Product/ProductList/Related.php
Something like
protected function _prepareData()
$product = $this->_coreRegistry->registry('product');
/* @var $product MagentoCatalogModelProduct */
// GET TYPE
$productType = $product->getTypeId();
// IF CONFIGURABLE
if ($productType == 'configurable')
$childrenProducts = $product->getTypeInstance()->getUsedProducts($product);
if ($childrenProducts)
$this->_itemCollection = array();
foreach ($childrenProducts as $singleChild)
$relatedProductCollection = $singleChild->getRelatedProductCollection()->addAttributeToSelect(
'required_options'
)->setPositionOrder()->addStoreFilter();
if ($this->moduleManager->isEnabled('Magento_Checkout'))
$this->_addProductAttributesAndPrices($relatedProductCollection);
$relatedProductCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
$relatedProductCollection->load();
foreach ($relatedProductCollection as $singleProduct)
$singleProduct->setDoNotUseCategoryId(true);
$this->_itemCollection[] = $singleProduct;
else
// IF OTHERS
// main FUNCITON CODE
return $this;
and then override the items.phtml
file
vendor/magento/module-catalog/view/frontend/templates/product/list/items.phtml
under case 'related'
change the if condition
if ($exist = $block->getItems()->getSize())
to
if ($exist = count($block->getItems()))
If you want to display related products of child items instead of the related products of the parent item in a configurable product structure, then
Create a new module and override _prepareData
function the main block file
vendor/magento/module-catalog/Block/Product/ProductList/Related.php
Something like
protected function _prepareData()
$product = $this->_coreRegistry->registry('product');
/* @var $product MagentoCatalogModelProduct */
// GET TYPE
$productType = $product->getTypeId();
// IF CONFIGURABLE
if ($productType == 'configurable')
$childrenProducts = $product->getTypeInstance()->getUsedProducts($product);
if ($childrenProducts)
$this->_itemCollection = array();
foreach ($childrenProducts as $singleChild)
$relatedProductCollection = $singleChild->getRelatedProductCollection()->addAttributeToSelect(
'required_options'
)->setPositionOrder()->addStoreFilter();
if ($this->moduleManager->isEnabled('Magento_Checkout'))
$this->_addProductAttributesAndPrices($relatedProductCollection);
$relatedProductCollection->setVisibility($this->_catalogProductVisibility->getVisibleInCatalogIds());
$relatedProductCollection->load();
foreach ($relatedProductCollection as $singleProduct)
$singleProduct->setDoNotUseCategoryId(true);
$this->_itemCollection[] = $singleProduct;
else
// IF OTHERS
// main FUNCITON CODE
return $this;
and then override the items.phtml
file
vendor/magento/module-catalog/view/frontend/templates/product/list/items.phtml
under case 'related'
change the if condition
if ($exist = $block->getItems()->getSize())
to
if ($exist = count($block->getItems()))
edited Sep 13 '18 at 14:54
answered Sep 13 '18 at 14:45
Hammad KhalidHammad Khalid
397212
397212
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f241496%2fneed-to-show-related-products-of-simple-product-in-configurable-product%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
ok but you can display only the products under configurable products that are visible and in stock with inventory will show. what you want here ?
– Charul Tyagi
Sep 10 '18 at 10:40
i need that when i select simple product for any configurable product that simple product related product data should also be shown as related product in configurable product
– Arjun
Sep 10 '18 at 11:01
so if you select any simple product it should be visibility should be catalog,search to front-end ,in stock and have inventory too then can list down in related products
– Charul Tyagi
Sep 10 '18 at 11:22
Ok let me recorrect myself when i redirect to any configurable product page i need to see related products on that page but that related products should not be of that configurable product but of all the simple products attach to that configurable product
– Arjun
Sep 10 '18 at 12:25