Grouped Product getAssociatedProducts() is not working in attributes tab templateMagento 1.9.0.1 Grouped Product Drop Down problem with sub-products quantityHow can i rewrite TierPrice Block in Magento2Add function to class M2Magento 1.9 - To get all simple(associated) products of grouped product regardless of websites/store viewsMagento 2 - Get simple product attributes on Grouped product detailpageAdd more columns and add to basket to the grid in grouped products Magento 2Call MagentoCatalogModelProduct::getData() returns nullNew product type which extend grouped productOverride function from grouped.phpHow to get tier prices for particular quantity in Magento 2?
Can a US president have someone sent to prison?
Should I include salary information on my CV?
can’t run a function against EXEC
Is there a short way to check uniqueness of values without using 'if' and multiple 'and's?
AT system without -5v
Do we or do we not observe (measure) superpositions all the time?
Averting Real Women Don’t Wear Dresses
How can I convince my reader that I will not use a certain trope?
Set vertical spacing between two particular items
Symbol for "not absolutely continuous" in Latex
Analog is Obtuse!
Articles before "covenant"?
Why cruise at 7000' in an A319?
Confusion about multiple information Sets
“Faire” being used to mean “avoir l’air”?
The difference between Rad1 and Rfd1
Professor Roman gives unusual math quiz ahead of
How can I create ribbons like these in Microsoft word 2010?
Does anycast addressing add additional latency in any way?
How can I check type T is among parameter pack Ts... in C++?
Why is a blank required between "[[" and "-e xxx" in ksh?
SPI Waveform on Raspberry Pi Not clean and I'm wondering why
The use of "I" and "we" used in the same sentence and other questions
Signing using digital signatures?
Grouped Product getAssociatedProducts() is not working in attributes tab template
Magento 1.9.0.1 Grouped Product Drop Down problem with sub-products quantityHow can i rewrite TierPrice Block in Magento2Add function to class M2Magento 1.9 - To get all simple(associated) products of grouped product regardless of websites/store viewsMagento 2 - Get simple product attributes on Grouped product detailpageAdd more columns and add to basket to the grid in grouped products Magento 2Call MagentoCatalogModelProduct::getData() returns nullNew product type which extend grouped productOverride function from grouped.phpHow to get tier prices for particular quantity in Magento 2?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
In the main view template for my grouped products, grouped.phtml, I have had no problems fetching the associated products and displaying some attributes in a loop.
I have done the same thing in a custom version of the attributes.phtml sub-template used to display attributes, and there, the code returns NULL.
<body>
<attribute name="class" value="page-product-grouped"/>
<referenceContainer name="product.info.form.content">
<block class="MagentoGroupedProductBlockProductViewTypeGrouped" name="product.info.grouped" before="product.info.addtocart" template="Magento_GroupedProduct::product/view/type/grouped.phtml"/>
<container name="product.info.grouped.extra" after="product.info.grouped" before="product.info.grouped" as="product_type_data_extra" label="Product Extra Info"/>
</referenceContainer>
(...)
<referenceBlock name="product.info.details">
<block class="MagentoCatalogBlockProductViewAttributes" name="product.attributes" as="additional" template="Magento_GroupedProduct::product/view/type/grouped/attributes.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">More Information</argument>
<argument name="sort_order" xsi:type="string">27</argument>
</arguments>
</block>
</referenceBlock>
</body>
I am assuming that the reason is because the second block is of class="MagentoCatalogBlockProductViewAttributes" but obviously if I change it to MagentoGroupedProductBlockProductViewTypeGrouped then the attribute functionality disappears so I am not better off.
There has to be a way to "cross load" the Grouped functionality into the Attributes block (or vice versa) OR I must use something other than $block for the grouped loading code:
$_product = $block->getProduct();
$_associatedProducts = $block->getAssociatedProducts();
but what?
magento2 product-attribute product-view grouped-products product-tab
add a comment |
In the main view template for my grouped products, grouped.phtml, I have had no problems fetching the associated products and displaying some attributes in a loop.
I have done the same thing in a custom version of the attributes.phtml sub-template used to display attributes, and there, the code returns NULL.
<body>
<attribute name="class" value="page-product-grouped"/>
<referenceContainer name="product.info.form.content">
<block class="MagentoGroupedProductBlockProductViewTypeGrouped" name="product.info.grouped" before="product.info.addtocart" template="Magento_GroupedProduct::product/view/type/grouped.phtml"/>
<container name="product.info.grouped.extra" after="product.info.grouped" before="product.info.grouped" as="product_type_data_extra" label="Product Extra Info"/>
</referenceContainer>
(...)
<referenceBlock name="product.info.details">
<block class="MagentoCatalogBlockProductViewAttributes" name="product.attributes" as="additional" template="Magento_GroupedProduct::product/view/type/grouped/attributes.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">More Information</argument>
<argument name="sort_order" xsi:type="string">27</argument>
</arguments>
</block>
</referenceBlock>
</body>
I am assuming that the reason is because the second block is of class="MagentoCatalogBlockProductViewAttributes" but obviously if I change it to MagentoGroupedProductBlockProductViewTypeGrouped then the attribute functionality disappears so I am not better off.
There has to be a way to "cross load" the Grouped functionality into the Attributes block (or vice versa) OR I must use something other than $block for the grouped loading code:
$_product = $block->getProduct();
$_associatedProducts = $block->getAssociatedProducts();
but what?
magento2 product-attribute product-view grouped-products product-tab
add a comment |
In the main view template for my grouped products, grouped.phtml, I have had no problems fetching the associated products and displaying some attributes in a loop.
I have done the same thing in a custom version of the attributes.phtml sub-template used to display attributes, and there, the code returns NULL.
<body>
<attribute name="class" value="page-product-grouped"/>
<referenceContainer name="product.info.form.content">
<block class="MagentoGroupedProductBlockProductViewTypeGrouped" name="product.info.grouped" before="product.info.addtocart" template="Magento_GroupedProduct::product/view/type/grouped.phtml"/>
<container name="product.info.grouped.extra" after="product.info.grouped" before="product.info.grouped" as="product_type_data_extra" label="Product Extra Info"/>
</referenceContainer>
(...)
<referenceBlock name="product.info.details">
<block class="MagentoCatalogBlockProductViewAttributes" name="product.attributes" as="additional" template="Magento_GroupedProduct::product/view/type/grouped/attributes.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">More Information</argument>
<argument name="sort_order" xsi:type="string">27</argument>
</arguments>
</block>
</referenceBlock>
</body>
I am assuming that the reason is because the second block is of class="MagentoCatalogBlockProductViewAttributes" but obviously if I change it to MagentoGroupedProductBlockProductViewTypeGrouped then the attribute functionality disappears so I am not better off.
There has to be a way to "cross load" the Grouped functionality into the Attributes block (or vice versa) OR I must use something other than $block for the grouped loading code:
$_product = $block->getProduct();
$_associatedProducts = $block->getAssociatedProducts();
but what?
magento2 product-attribute product-view grouped-products product-tab
In the main view template for my grouped products, grouped.phtml, I have had no problems fetching the associated products and displaying some attributes in a loop.
I have done the same thing in a custom version of the attributes.phtml sub-template used to display attributes, and there, the code returns NULL.
<body>
<attribute name="class" value="page-product-grouped"/>
<referenceContainer name="product.info.form.content">
<block class="MagentoGroupedProductBlockProductViewTypeGrouped" name="product.info.grouped" before="product.info.addtocart" template="Magento_GroupedProduct::product/view/type/grouped.phtml"/>
<container name="product.info.grouped.extra" after="product.info.grouped" before="product.info.grouped" as="product_type_data_extra" label="Product Extra Info"/>
</referenceContainer>
(...)
<referenceBlock name="product.info.details">
<block class="MagentoCatalogBlockProductViewAttributes" name="product.attributes" as="additional" template="Magento_GroupedProduct::product/view/type/grouped/attributes.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">More Information</argument>
<argument name="sort_order" xsi:type="string">27</argument>
</arguments>
</block>
</referenceBlock>
</body>
I am assuming that the reason is because the second block is of class="MagentoCatalogBlockProductViewAttributes" but obviously if I change it to MagentoGroupedProductBlockProductViewTypeGrouped then the attribute functionality disappears so I am not better off.
There has to be a way to "cross load" the Grouped functionality into the Attributes block (or vice versa) OR I must use something other than $block for the grouped loading code:
$_product = $block->getProduct();
$_associatedProducts = $block->getAssociatedProducts();
but what?
magento2 product-attribute product-view grouped-products product-tab
magento2 product-attribute product-view grouped-products product-tab
edited Jun 17 at 16:05
iphigenie
asked Jun 17 at 15:34
iphigenieiphigenie
4912 silver badges16 bronze badges
4912 silver badges16 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
This is what I understood the question is.
I need the associated products in a template in which I have access to
the product. How do I do that?
From the product object you can retrieve the type instance. And from the type instance you can retrieve the associated products.
$associatedProducts = $product->getTypeInstance()->getAssociatedProducts($product);
If your product is grouped, getTypeInstance() will return a MagentoGroupedProductModelProductTypeGrouped instance which implements getAssociatedProducts it also implements getAssociatedProductsCollection if you want to add some extra filters.
I hope this answers your question. If I did not get the question right, please put me on the right track.
Thanks - that certainly "loaded up" the grouped context as I needed. Silly question perhaps but if I have already loaded the associated products for this very product in another subtemplate, is this redoing the whole querying and building the whole information again? In a way the groupedproduct codebase should extend attributes too so there is no such need.
– iphigenie
Jun 18 at 14:23
It's a good question. I'm not really sure. You will have to investigate if the same collection is used in both places. There are big chances that the same collection(same instance, not type) is used in both places. A run with the debugger could answer the q.
– vitoriodachef
Jun 18 at 14:28
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%2f278628%2fgrouped-product-getassociatedproducts-is-not-working-in-attributes-tab-templat%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
This is what I understood the question is.
I need the associated products in a template in which I have access to
the product. How do I do that?
From the product object you can retrieve the type instance. And from the type instance you can retrieve the associated products.
$associatedProducts = $product->getTypeInstance()->getAssociatedProducts($product);
If your product is grouped, getTypeInstance() will return a MagentoGroupedProductModelProductTypeGrouped instance which implements getAssociatedProducts it also implements getAssociatedProductsCollection if you want to add some extra filters.
I hope this answers your question. If I did not get the question right, please put me on the right track.
Thanks - that certainly "loaded up" the grouped context as I needed. Silly question perhaps but if I have already loaded the associated products for this very product in another subtemplate, is this redoing the whole querying and building the whole information again? In a way the groupedproduct codebase should extend attributes too so there is no such need.
– iphigenie
Jun 18 at 14:23
It's a good question. I'm not really sure. You will have to investigate if the same collection is used in both places. There are big chances that the same collection(same instance, not type) is used in both places. A run with the debugger could answer the q.
– vitoriodachef
Jun 18 at 14:28
add a comment |
This is what I understood the question is.
I need the associated products in a template in which I have access to
the product. How do I do that?
From the product object you can retrieve the type instance. And from the type instance you can retrieve the associated products.
$associatedProducts = $product->getTypeInstance()->getAssociatedProducts($product);
If your product is grouped, getTypeInstance() will return a MagentoGroupedProductModelProductTypeGrouped instance which implements getAssociatedProducts it also implements getAssociatedProductsCollection if you want to add some extra filters.
I hope this answers your question. If I did not get the question right, please put me on the right track.
Thanks - that certainly "loaded up" the grouped context as I needed. Silly question perhaps but if I have already loaded the associated products for this very product in another subtemplate, is this redoing the whole querying and building the whole information again? In a way the groupedproduct codebase should extend attributes too so there is no such need.
– iphigenie
Jun 18 at 14:23
It's a good question. I'm not really sure. You will have to investigate if the same collection is used in both places. There are big chances that the same collection(same instance, not type) is used in both places. A run with the debugger could answer the q.
– vitoriodachef
Jun 18 at 14:28
add a comment |
This is what I understood the question is.
I need the associated products in a template in which I have access to
the product. How do I do that?
From the product object you can retrieve the type instance. And from the type instance you can retrieve the associated products.
$associatedProducts = $product->getTypeInstance()->getAssociatedProducts($product);
If your product is grouped, getTypeInstance() will return a MagentoGroupedProductModelProductTypeGrouped instance which implements getAssociatedProducts it also implements getAssociatedProductsCollection if you want to add some extra filters.
I hope this answers your question. If I did not get the question right, please put me on the right track.
This is what I understood the question is.
I need the associated products in a template in which I have access to
the product. How do I do that?
From the product object you can retrieve the type instance. And from the type instance you can retrieve the associated products.
$associatedProducts = $product->getTypeInstance()->getAssociatedProducts($product);
If your product is grouped, getTypeInstance() will return a MagentoGroupedProductModelProductTypeGrouped instance which implements getAssociatedProducts it also implements getAssociatedProductsCollection if you want to add some extra filters.
I hope this answers your question. If I did not get the question right, please put me on the right track.
answered Jun 17 at 20:19
vitoriodachefvitoriodachef
1,4784 silver badges24 bronze badges
1,4784 silver badges24 bronze badges
Thanks - that certainly "loaded up" the grouped context as I needed. Silly question perhaps but if I have already loaded the associated products for this very product in another subtemplate, is this redoing the whole querying and building the whole information again? In a way the groupedproduct codebase should extend attributes too so there is no such need.
– iphigenie
Jun 18 at 14:23
It's a good question. I'm not really sure. You will have to investigate if the same collection is used in both places. There are big chances that the same collection(same instance, not type) is used in both places. A run with the debugger could answer the q.
– vitoriodachef
Jun 18 at 14:28
add a comment |
Thanks - that certainly "loaded up" the grouped context as I needed. Silly question perhaps but if I have already loaded the associated products for this very product in another subtemplate, is this redoing the whole querying and building the whole information again? In a way the groupedproduct codebase should extend attributes too so there is no such need.
– iphigenie
Jun 18 at 14:23
It's a good question. I'm not really sure. You will have to investigate if the same collection is used in both places. There are big chances that the same collection(same instance, not type) is used in both places. A run with the debugger could answer the q.
– vitoriodachef
Jun 18 at 14:28
Thanks - that certainly "loaded up" the grouped context as I needed. Silly question perhaps but if I have already loaded the associated products for this very product in another subtemplate, is this redoing the whole querying and building the whole information again? In a way the groupedproduct codebase should extend attributes too so there is no such need.
– iphigenie
Jun 18 at 14:23
Thanks - that certainly "loaded up" the grouped context as I needed. Silly question perhaps but if I have already loaded the associated products for this very product in another subtemplate, is this redoing the whole querying and building the whole information again? In a way the groupedproduct codebase should extend attributes too so there is no such need.
– iphigenie
Jun 18 at 14:23
It's a good question. I'm not really sure. You will have to investigate if the same collection is used in both places. There are big chances that the same collection(same instance, not type) is used in both places. A run with the debugger could answer the q.
– vitoriodachef
Jun 18 at 14:28
It's a good question. I'm not really sure. You will have to investigate if the same collection is used in both places. There are big chances that the same collection(same instance, not type) is used in both places. A run with the debugger could answer the q.
– vitoriodachef
Jun 18 at 14:28
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%2f278628%2fgrouped-product-getassociatedproducts-is-not-working-in-attributes-tab-templat%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