Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

May I ask why getAttributeSafe was added? #68

Open
seansan opened this issue Jan 15, 2019 · 1 comment
Open

May I ask why getAttributeSafe was added? #68

seansan opened this issue Jan 15, 2019 · 1 comment

Comments

@seansan
Copy link
Contributor

seansan commented Jan 15, 2019

getAttributeSafe : does this not slow the whole procedure down?

Why not use getManufacturer? or use a dummy function with a param for the correct Manufacturer attribute key?

public function getAttributeSafe($product, $attribute)

@seansan
Copy link
Contributor Author

seansan commented Jan 15, 2019

Got it.

Dont know which one is faster?

/* Returns array of sizes data - and flexible to use in Product.php because of param */
public function getRawAttribute($attribute_code, $force_get = false)
{
    $value = '';
    $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $attribute_code);
    if ($force_get) {
        $value = $this->getData($attribute_code);
    } else if($attribute->usesSource()) {
        $value = $this->getAttributeText($attribute_code);
    } else if ($value = $this->getData($attribute_code)) {
        $value = $value;
    } else {
        $value = Mage::getResourceModel('catalog/product')->getAttributeRawValue($this->getId(), $attribute_code, $this->getStore());
    }
    return $value;
}

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

No branches or pull requests

1 participant