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

Dont show Shippingcost link when product is configurable and only consists from virtual products #141

Open
Flyingmana opened this issue Feb 18, 2015 · 6 comments
Labels

Comments

@Flyingmana
Copy link
Member

If you have a configurable, but only add virtual products as children, there is still the sippingcost link.

The reason I think is this code:
https://github.com/firegento/firegento-magesetup/blob/2.2.1/src/app/code/community/FireGento/MageSetup/Block/Catalog/Product/Price.php#L203

Source: IRC

@riconeitzel
Copy link
Member

we're happy to see a PR here :-)

@sreichel
Copy link
Contributor

This should work ... can someone confirm before a create a PR?

public function isShowShippingLink()
{
    $productTypeId = $this->getProduct()->getTypeId();
    $ignoreTypeIds = array('virtual', 'downloadable');

    // --- fix
    if ($productTypeId === 'configurable') {
        $childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $this->getProduct());

        foreach ($childProducts as $child) {
            if (!in_array($child->getTypeId(), $ignoreTypeIds)) {
                return true;
            }
        }
        return false;
    }
    // ---

    if (in_array($productTypeId, $ignoreTypeIds)) {
        return false;
    }

    return true;
}

@sprankhub
Copy link
Member

Thanks. I fear to be the bad guy again :D but I am not sure if we should include that. It looks good and should work, but the getUsedProducts method has a significant performance footprint. If the block is cached properly, this may be okay. But I think only few people use virtual products (at least in combination with configurable products), so that it may be better to ignore that issue...

@Schrank
Copy link
Member

Schrank commented May 2, 2017

I agree here with @sprankhub. We can fix this by implementing our own ResourceModel to get this info directly from database without getUsedProducts AND cache it :-)

@riconeitzel
Copy link
Member

@Schrank any code available yet? @sprankhub you perhaps?!

@sprankhub
Copy link
Member

Unfortunately not, sorry...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants