Handling grouped product attributes Planned maintenance scheduled April 17/18, 2019 at...
Is 1 ppb equal to 1 μg/kg?
Can inflation occur in a positive-sum game currency system such as the Stack Exchange reputation system?
How discoverable are IPv6 addresses and AAAA names by potential attackers?
Why does Python start at index 1 when iterating an array backwards?
How do I determine if the rules for a long jump or high jump are applicable for Monks?
What is the musical term for a note that continously plays through a melody?
How do I keep my slimes from escaping their pens?
ListPlot join points by nearest neighbor rather than order
What happens to sewage if there is no river near by?
Is there a documented rationale why the House Ways and Means chairman can demand tax info?
Gastric acid as a weapon
Is there a service that would inform me whenever a new direct route is scheduled from a given airport?
If a contract sometimes uses the wrong name, is it still valid?
Are my PIs rude or am I just being too sensitive?
Should I use Javascript Classes or Apex Classes in Lightning Web Components?
How does cp -a work
Why is high voltage dangerous?
What makes black pepper strong or mild?
Doubts about chords
Java 8 stream max() function argument type Comparator vs Comparable
How to motivate offshore teams and trust them to deliver?
Is there a way in Ruby to make just any one out of many keyword arguments required?
Should I discuss the type of campaign with my players?
IndentationError when pasting code in Python 3 interpreter mode
Handling grouped product attributes
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Select multiple product options at onceLooking for a way to extend attributesBest Practices for Planning Attributes and Attribute SetsMultiple Select - Render as url and searchMagmi: Attributes not being associated with attribute setsMagento 2 - Export/Import Product AttributesImporting attribute sets into Magento programmatically? Magmi?Old attributes persist after attribute set is changed in Magento 2How to change dynamic attributes when simple product is selectedGrouped Products: Filter based on simple productsProgrammatically Delete Product Attribute Sets
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I'm working on building a new Magento shop (this is my first with Magento).
I'm looking to replicate the look of an existing shop for my product pages, at least in terms of layout:
http://www.panamericantool.com/cobalt-drills/drill-stops.html
http://www.panamericantool.com/screw-driver-bits/paint-cutters.html
I've figured out that I need to use grouped products, with simple products to create the kind of thing I'm after.
In the examples above, each product has separate attributes, I assume these are done via different attribute sets in Magento.
However how do they go displaying those different table headings/values in the theme?
I know I can do ->getAttributeName()
or ->getAttribute('attribute_code')
in the grouped.phtml
file, but this would result in a vast amount of if (->getAttributeName() != '')...
and I'd need to change the template when adding more.
I'm sure there is a way of getting all attributes and looping over them, but then how would you differentiate between say the meta_description
attribute (also returned by the $_product->getData()
method) and an attribute I'd want listed in the table?
How could I achieve something akin to what they have?
I'm also concerned about performance the shop will have 5k products at launch, growing to perhaps 25k-30k as we add our remaining stock. Many of these will need different attributes, but I'm guessing I could share attributes between attribute sets without too many performance issues?
Update:
I've carried on playing around with this, I've found this to get all of a products attributes, however I still don't know of a simple way of showing on certain values on a grouped product table?
$attributes = Mage::getModel('catalog/product_attribute_api')->items($_product->getAttributeSetId());
foreach($attributes as $_attribute){
print_r($_attribute);
}
magento-1.9 attributes product-attribute grouped-products attribute-set
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I'm working on building a new Magento shop (this is my first with Magento).
I'm looking to replicate the look of an existing shop for my product pages, at least in terms of layout:
http://www.panamericantool.com/cobalt-drills/drill-stops.html
http://www.panamericantool.com/screw-driver-bits/paint-cutters.html
I've figured out that I need to use grouped products, with simple products to create the kind of thing I'm after.
In the examples above, each product has separate attributes, I assume these are done via different attribute sets in Magento.
However how do they go displaying those different table headings/values in the theme?
I know I can do ->getAttributeName()
or ->getAttribute('attribute_code')
in the grouped.phtml
file, but this would result in a vast amount of if (->getAttributeName() != '')...
and I'd need to change the template when adding more.
I'm sure there is a way of getting all attributes and looping over them, but then how would you differentiate between say the meta_description
attribute (also returned by the $_product->getData()
method) and an attribute I'd want listed in the table?
How could I achieve something akin to what they have?
I'm also concerned about performance the shop will have 5k products at launch, growing to perhaps 25k-30k as we add our remaining stock. Many of these will need different attributes, but I'm guessing I could share attributes between attribute sets without too many performance issues?
Update:
I've carried on playing around with this, I've found this to get all of a products attributes, however I still don't know of a simple way of showing on certain values on a grouped product table?
$attributes = Mage::getModel('catalog/product_attribute_api')->items($_product->getAttributeSetId());
foreach($attributes as $_attribute){
print_r($_attribute);
}
magento-1.9 attributes product-attribute grouped-products attribute-set
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Why not use the "Visible on Product View Page on Front-end" property of the attribute to determine whether to show it on the product page?
– BlueC
May 26 '16 at 20:26
add a comment |
I'm working on building a new Magento shop (this is my first with Magento).
I'm looking to replicate the look of an existing shop for my product pages, at least in terms of layout:
http://www.panamericantool.com/cobalt-drills/drill-stops.html
http://www.panamericantool.com/screw-driver-bits/paint-cutters.html
I've figured out that I need to use grouped products, with simple products to create the kind of thing I'm after.
In the examples above, each product has separate attributes, I assume these are done via different attribute sets in Magento.
However how do they go displaying those different table headings/values in the theme?
I know I can do ->getAttributeName()
or ->getAttribute('attribute_code')
in the grouped.phtml
file, but this would result in a vast amount of if (->getAttributeName() != '')...
and I'd need to change the template when adding more.
I'm sure there is a way of getting all attributes and looping over them, but then how would you differentiate between say the meta_description
attribute (also returned by the $_product->getData()
method) and an attribute I'd want listed in the table?
How could I achieve something akin to what they have?
I'm also concerned about performance the shop will have 5k products at launch, growing to perhaps 25k-30k as we add our remaining stock. Many of these will need different attributes, but I'm guessing I could share attributes between attribute sets without too many performance issues?
Update:
I've carried on playing around with this, I've found this to get all of a products attributes, however I still don't know of a simple way of showing on certain values on a grouped product table?
$attributes = Mage::getModel('catalog/product_attribute_api')->items($_product->getAttributeSetId());
foreach($attributes as $_attribute){
print_r($_attribute);
}
magento-1.9 attributes product-attribute grouped-products attribute-set
I'm working on building a new Magento shop (this is my first with Magento).
I'm looking to replicate the look of an existing shop for my product pages, at least in terms of layout:
http://www.panamericantool.com/cobalt-drills/drill-stops.html
http://www.panamericantool.com/screw-driver-bits/paint-cutters.html
I've figured out that I need to use grouped products, with simple products to create the kind of thing I'm after.
In the examples above, each product has separate attributes, I assume these are done via different attribute sets in Magento.
However how do they go displaying those different table headings/values in the theme?
I know I can do ->getAttributeName()
or ->getAttribute('attribute_code')
in the grouped.phtml
file, but this would result in a vast amount of if (->getAttributeName() != '')...
and I'd need to change the template when adding more.
I'm sure there is a way of getting all attributes and looping over them, but then how would you differentiate between say the meta_description
attribute (also returned by the $_product->getData()
method) and an attribute I'd want listed in the table?
How could I achieve something akin to what they have?
I'm also concerned about performance the shop will have 5k products at launch, growing to perhaps 25k-30k as we add our remaining stock. Many of these will need different attributes, but I'm guessing I could share attributes between attribute sets without too many performance issues?
Update:
I've carried on playing around with this, I've found this to get all of a products attributes, however I still don't know of a simple way of showing on certain values on a grouped product table?
$attributes = Mage::getModel('catalog/product_attribute_api')->items($_product->getAttributeSetId());
foreach($attributes as $_attribute){
print_r($_attribute);
}
magento-1.9 attributes product-attribute grouped-products attribute-set
magento-1.9 attributes product-attribute grouped-products attribute-set
edited Apr 13 '17 at 12:54
Community♦
1
1
asked Mar 2 '15 at 12:00
Tom GreenTom Green
1336
1336
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Why not use the "Visible on Product View Page on Front-end" property of the attribute to determine whether to show it on the product page?
– BlueC
May 26 '16 at 20:26
add a comment |
Why not use the "Visible on Product View Page on Front-end" property of the attribute to determine whether to show it on the product page?
– BlueC
May 26 '16 at 20:26
Why not use the "Visible on Product View Page on Front-end" property of the attribute to determine whether to show it on the product page?
– BlueC
May 26 '16 at 20:26
Why not use the "Visible on Product View Page on Front-end" property of the attribute to determine whether to show it on the product page?
– BlueC
May 26 '16 at 20:26
add a comment |
2 Answers
2
active
oldest
votes
This should be what you need:
$product->getResource()->getAttribute('attribute_code')->getStoreLabel();
But this would just get a single attribute, I need a way of showing different attributes for different products - as per the links I included in the OP?
– Tom Green
Mar 3 '15 at 13:01
add a comment |
Why not create an attribute that tells it what attributes to show?
I ended up creating a module that loads the value of two text attributes for grouped products that are attribute code strings. Essentially a helper that Explodes that attribute list string and loops over it to load the associated products attribute data.
Create an attribute I called mine:
grouped_attr_array
Add the attribute to the grouped product's design attribute set in the admin and then them as a semicolon separated field in the product data
torque_range;torque_increments;torque_accuracy
I pulled this code from my module. It's doing some more loading or hiding of default attributes based on a an attribute value and the module is a little more complex. But to get the data shown in the table these are some of the core functions. Hopefully it gives you an idea to build on. This is using magento 1.9.2
The Module's Helper:
public function findAttributes($product, $attributes)
{
//determined by attribute with id to add additional attributes to the table
//string needs to be ; separated in ADMIN
$strattributes = $product->getResource()->getAttribute('grouped_attr_array')->getFrontend()->getValue($product);
if ($strattributes) {
$strattributes = explode(';', $strattributes, 5);
foreach ($strattributes as $additionAttribute) {
//make sure these are valid attributes
if ($product->getResource()->getAttribute($additionAttribute)) {
array_push($attributes, $additionAttribute);
}
}
}
}
public function groupedAttrDump($groupedProduct, $attributes)
{
$cells = [];
foreach ($attributes as $attrCode) {
$attrText = $groupedProduct->getResource()->getAttribute($attrCode);
if($attrText){
array_push($cells, $attrText->getFrontend()->getValue($groupedProduct));
}
}
return $cells;
}
public function groupedAttrHeaders($currentProduct, $attributes)
{
$theads = [];
foreach ($attributes as $attrCode) {
$headerText = $currentProduct->getResource()->getAttribute($attrCode);
if($headerText){
$headerText = $headerText->getStoreLabel();
array_push($theads,$headerText);
}
}
return $theads;
}
Getting Data from helper in groupedproduct.phtml
$attrrSetName = Mage::getModel("eav/entity_attribute_set")->load($_product->getAttributeSetId())->getAttributeSetName();
$tableAttributes = Mage::helper('groupedtable')->findAttributes($_product, $attrrSetName);
TH's
<?php foreach (Mage::helper('groupedtable')->groupedAttrHeaders($_product, $tableAttributes) as $attrLabel ): ?>
<th><?php echo $attrLabel ?> </th>
<?php endforeach; ?>
TD's the table
<?php foreach (Mage::helper('groupedtable')->groupedAttrDump($_associatedProduct, $tableAttributes) as $attr ):?>
<td><?php if($attr != 'No'){ echo $attr; } ?></td>
<?php endforeach; ?>
I'd like to build out the way of choosing that attribute based on the store's available attributes. Maybe there'a much better way to do this too. Haven't gotten to that yet.
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%2f59241%2fhandling-grouped-product-attributes%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
This should be what you need:
$product->getResource()->getAttribute('attribute_code')->getStoreLabel();
But this would just get a single attribute, I need a way of showing different attributes for different products - as per the links I included in the OP?
– Tom Green
Mar 3 '15 at 13:01
add a comment |
This should be what you need:
$product->getResource()->getAttribute('attribute_code')->getStoreLabel();
But this would just get a single attribute, I need a way of showing different attributes for different products - as per the links I included in the OP?
– Tom Green
Mar 3 '15 at 13:01
add a comment |
This should be what you need:
$product->getResource()->getAttribute('attribute_code')->getStoreLabel();
This should be what you need:
$product->getResource()->getAttribute('attribute_code')->getStoreLabel();
answered Mar 2 '15 at 19:35
benmarks♦benmarks
15.3k436105
15.3k436105
But this would just get a single attribute, I need a way of showing different attributes for different products - as per the links I included in the OP?
– Tom Green
Mar 3 '15 at 13:01
add a comment |
But this would just get a single attribute, I need a way of showing different attributes for different products - as per the links I included in the OP?
– Tom Green
Mar 3 '15 at 13:01
But this would just get a single attribute, I need a way of showing different attributes for different products - as per the links I included in the OP?
– Tom Green
Mar 3 '15 at 13:01
But this would just get a single attribute, I need a way of showing different attributes for different products - as per the links I included in the OP?
– Tom Green
Mar 3 '15 at 13:01
add a comment |
Why not create an attribute that tells it what attributes to show?
I ended up creating a module that loads the value of two text attributes for grouped products that are attribute code strings. Essentially a helper that Explodes that attribute list string and loops over it to load the associated products attribute data.
Create an attribute I called mine:
grouped_attr_array
Add the attribute to the grouped product's design attribute set in the admin and then them as a semicolon separated field in the product data
torque_range;torque_increments;torque_accuracy
I pulled this code from my module. It's doing some more loading or hiding of default attributes based on a an attribute value and the module is a little more complex. But to get the data shown in the table these are some of the core functions. Hopefully it gives you an idea to build on. This is using magento 1.9.2
The Module's Helper:
public function findAttributes($product, $attributes)
{
//determined by attribute with id to add additional attributes to the table
//string needs to be ; separated in ADMIN
$strattributes = $product->getResource()->getAttribute('grouped_attr_array')->getFrontend()->getValue($product);
if ($strattributes) {
$strattributes = explode(';', $strattributes, 5);
foreach ($strattributes as $additionAttribute) {
//make sure these are valid attributes
if ($product->getResource()->getAttribute($additionAttribute)) {
array_push($attributes, $additionAttribute);
}
}
}
}
public function groupedAttrDump($groupedProduct, $attributes)
{
$cells = [];
foreach ($attributes as $attrCode) {
$attrText = $groupedProduct->getResource()->getAttribute($attrCode);
if($attrText){
array_push($cells, $attrText->getFrontend()->getValue($groupedProduct));
}
}
return $cells;
}
public function groupedAttrHeaders($currentProduct, $attributes)
{
$theads = [];
foreach ($attributes as $attrCode) {
$headerText = $currentProduct->getResource()->getAttribute($attrCode);
if($headerText){
$headerText = $headerText->getStoreLabel();
array_push($theads,$headerText);
}
}
return $theads;
}
Getting Data from helper in groupedproduct.phtml
$attrrSetName = Mage::getModel("eav/entity_attribute_set")->load($_product->getAttributeSetId())->getAttributeSetName();
$tableAttributes = Mage::helper('groupedtable')->findAttributes($_product, $attrrSetName);
TH's
<?php foreach (Mage::helper('groupedtable')->groupedAttrHeaders($_product, $tableAttributes) as $attrLabel ): ?>
<th><?php echo $attrLabel ?> </th>
<?php endforeach; ?>
TD's the table
<?php foreach (Mage::helper('groupedtable')->groupedAttrDump($_associatedProduct, $tableAttributes) as $attr ):?>
<td><?php if($attr != 'No'){ echo $attr; } ?></td>
<?php endforeach; ?>
I'd like to build out the way of choosing that attribute based on the store's available attributes. Maybe there'a much better way to do this too. Haven't gotten to that yet.
add a comment |
Why not create an attribute that tells it what attributes to show?
I ended up creating a module that loads the value of two text attributes for grouped products that are attribute code strings. Essentially a helper that Explodes that attribute list string and loops over it to load the associated products attribute data.
Create an attribute I called mine:
grouped_attr_array
Add the attribute to the grouped product's design attribute set in the admin and then them as a semicolon separated field in the product data
torque_range;torque_increments;torque_accuracy
I pulled this code from my module. It's doing some more loading or hiding of default attributes based on a an attribute value and the module is a little more complex. But to get the data shown in the table these are some of the core functions. Hopefully it gives you an idea to build on. This is using magento 1.9.2
The Module's Helper:
public function findAttributes($product, $attributes)
{
//determined by attribute with id to add additional attributes to the table
//string needs to be ; separated in ADMIN
$strattributes = $product->getResource()->getAttribute('grouped_attr_array')->getFrontend()->getValue($product);
if ($strattributes) {
$strattributes = explode(';', $strattributes, 5);
foreach ($strattributes as $additionAttribute) {
//make sure these are valid attributes
if ($product->getResource()->getAttribute($additionAttribute)) {
array_push($attributes, $additionAttribute);
}
}
}
}
public function groupedAttrDump($groupedProduct, $attributes)
{
$cells = [];
foreach ($attributes as $attrCode) {
$attrText = $groupedProduct->getResource()->getAttribute($attrCode);
if($attrText){
array_push($cells, $attrText->getFrontend()->getValue($groupedProduct));
}
}
return $cells;
}
public function groupedAttrHeaders($currentProduct, $attributes)
{
$theads = [];
foreach ($attributes as $attrCode) {
$headerText = $currentProduct->getResource()->getAttribute($attrCode);
if($headerText){
$headerText = $headerText->getStoreLabel();
array_push($theads,$headerText);
}
}
return $theads;
}
Getting Data from helper in groupedproduct.phtml
$attrrSetName = Mage::getModel("eav/entity_attribute_set")->load($_product->getAttributeSetId())->getAttributeSetName();
$tableAttributes = Mage::helper('groupedtable')->findAttributes($_product, $attrrSetName);
TH's
<?php foreach (Mage::helper('groupedtable')->groupedAttrHeaders($_product, $tableAttributes) as $attrLabel ): ?>
<th><?php echo $attrLabel ?> </th>
<?php endforeach; ?>
TD's the table
<?php foreach (Mage::helper('groupedtable')->groupedAttrDump($_associatedProduct, $tableAttributes) as $attr ):?>
<td><?php if($attr != 'No'){ echo $attr; } ?></td>
<?php endforeach; ?>
I'd like to build out the way of choosing that attribute based on the store's available attributes. Maybe there'a much better way to do this too. Haven't gotten to that yet.
add a comment |
Why not create an attribute that tells it what attributes to show?
I ended up creating a module that loads the value of two text attributes for grouped products that are attribute code strings. Essentially a helper that Explodes that attribute list string and loops over it to load the associated products attribute data.
Create an attribute I called mine:
grouped_attr_array
Add the attribute to the grouped product's design attribute set in the admin and then them as a semicolon separated field in the product data
torque_range;torque_increments;torque_accuracy
I pulled this code from my module. It's doing some more loading or hiding of default attributes based on a an attribute value and the module is a little more complex. But to get the data shown in the table these are some of the core functions. Hopefully it gives you an idea to build on. This is using magento 1.9.2
The Module's Helper:
public function findAttributes($product, $attributes)
{
//determined by attribute with id to add additional attributes to the table
//string needs to be ; separated in ADMIN
$strattributes = $product->getResource()->getAttribute('grouped_attr_array')->getFrontend()->getValue($product);
if ($strattributes) {
$strattributes = explode(';', $strattributes, 5);
foreach ($strattributes as $additionAttribute) {
//make sure these are valid attributes
if ($product->getResource()->getAttribute($additionAttribute)) {
array_push($attributes, $additionAttribute);
}
}
}
}
public function groupedAttrDump($groupedProduct, $attributes)
{
$cells = [];
foreach ($attributes as $attrCode) {
$attrText = $groupedProduct->getResource()->getAttribute($attrCode);
if($attrText){
array_push($cells, $attrText->getFrontend()->getValue($groupedProduct));
}
}
return $cells;
}
public function groupedAttrHeaders($currentProduct, $attributes)
{
$theads = [];
foreach ($attributes as $attrCode) {
$headerText = $currentProduct->getResource()->getAttribute($attrCode);
if($headerText){
$headerText = $headerText->getStoreLabel();
array_push($theads,$headerText);
}
}
return $theads;
}
Getting Data from helper in groupedproduct.phtml
$attrrSetName = Mage::getModel("eav/entity_attribute_set")->load($_product->getAttributeSetId())->getAttributeSetName();
$tableAttributes = Mage::helper('groupedtable')->findAttributes($_product, $attrrSetName);
TH's
<?php foreach (Mage::helper('groupedtable')->groupedAttrHeaders($_product, $tableAttributes) as $attrLabel ): ?>
<th><?php echo $attrLabel ?> </th>
<?php endforeach; ?>
TD's the table
<?php foreach (Mage::helper('groupedtable')->groupedAttrDump($_associatedProduct, $tableAttributes) as $attr ):?>
<td><?php if($attr != 'No'){ echo $attr; } ?></td>
<?php endforeach; ?>
I'd like to build out the way of choosing that attribute based on the store's available attributes. Maybe there'a much better way to do this too. Haven't gotten to that yet.
Why not create an attribute that tells it what attributes to show?
I ended up creating a module that loads the value of two text attributes for grouped products that are attribute code strings. Essentially a helper that Explodes that attribute list string and loops over it to load the associated products attribute data.
Create an attribute I called mine:
grouped_attr_array
Add the attribute to the grouped product's design attribute set in the admin and then them as a semicolon separated field in the product data
torque_range;torque_increments;torque_accuracy
I pulled this code from my module. It's doing some more loading or hiding of default attributes based on a an attribute value and the module is a little more complex. But to get the data shown in the table these are some of the core functions. Hopefully it gives you an idea to build on. This is using magento 1.9.2
The Module's Helper:
public function findAttributes($product, $attributes)
{
//determined by attribute with id to add additional attributes to the table
//string needs to be ; separated in ADMIN
$strattributes = $product->getResource()->getAttribute('grouped_attr_array')->getFrontend()->getValue($product);
if ($strattributes) {
$strattributes = explode(';', $strattributes, 5);
foreach ($strattributes as $additionAttribute) {
//make sure these are valid attributes
if ($product->getResource()->getAttribute($additionAttribute)) {
array_push($attributes, $additionAttribute);
}
}
}
}
public function groupedAttrDump($groupedProduct, $attributes)
{
$cells = [];
foreach ($attributes as $attrCode) {
$attrText = $groupedProduct->getResource()->getAttribute($attrCode);
if($attrText){
array_push($cells, $attrText->getFrontend()->getValue($groupedProduct));
}
}
return $cells;
}
public function groupedAttrHeaders($currentProduct, $attributes)
{
$theads = [];
foreach ($attributes as $attrCode) {
$headerText = $currentProduct->getResource()->getAttribute($attrCode);
if($headerText){
$headerText = $headerText->getStoreLabel();
array_push($theads,$headerText);
}
}
return $theads;
}
Getting Data from helper in groupedproduct.phtml
$attrrSetName = Mage::getModel("eav/entity_attribute_set")->load($_product->getAttributeSetId())->getAttributeSetName();
$tableAttributes = Mage::helper('groupedtable')->findAttributes($_product, $attrrSetName);
TH's
<?php foreach (Mage::helper('groupedtable')->groupedAttrHeaders($_product, $tableAttributes) as $attrLabel ): ?>
<th><?php echo $attrLabel ?> </th>
<?php endforeach; ?>
TD's the table
<?php foreach (Mage::helper('groupedtable')->groupedAttrDump($_associatedProduct, $tableAttributes) as $attr ):?>
<td><?php if($attr != 'No'){ echo $attr; } ?></td>
<?php endforeach; ?>
I'd like to build out the way of choosing that attribute based on the store's available attributes. Maybe there'a much better way to do this too. Haven't gotten to that yet.
answered May 26 '16 at 20:20
asherrardasherrard
1666
1666
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%2f59241%2fhandling-grouped-product-attributes%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
Why not use the "Visible on Product View Page on Front-end" property of the attribute to determine whether to show it on the product page?
– BlueC
May 26 '16 at 20:26