Skip to content

Conversation

seansan
Copy link
Contributor

@seansan seansan commented Jan 15, 2019

No description provided.

@seansan
Copy link
Contributor Author

seansan commented Jan 15, 2019

@hkb Sorry about that, made it more robust for 'any' attribute

/* Returns array of sizes data - and flexible to use in Product.php because of param */
public function getChildAttribute($attribute_code)
{
    $values = array();
    if($this->isConfigurable()){
        $all = $this->getTypeInstance(true)->getUsedProducts(null, $this);
        foreach ($all as $child) {
            if ($child->isSaleable()) { 
                $values[] = $child->getAttributeText($attribute_code); 
                /* Get the ID $values[] = $child->getData($attribute_code); */
            }
        }
    } else {
        $values[] = $this->getAttributeText($attribute_code);
    }

    return $values;
}

@seansan
Copy link
Contributor Author

seansan commented Jan 15, 2019

Can also add an optional flag

$val = true

if $val = true get value if set to false then get the ID

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant