1

I have modified the bundled product view template so that the "checkboxed" product options are displayed with links back to their component products using $_product = Mage::getModel, etc.

The problem I'm having is, I need to not show a link if the item is not visible in the website/catalog, and include the link only if the item is visible in the catlog.

Here's a recent version of the code:

<?php $_option = $this->getOption() ?>
<?php $_selections = $_option->getSelections() ?>

....

$_product = Mage::getModel('catalog/product');
$_product->load($_selection->getProductId());

....

<?php if($_selection->getVisibleInSiteVisibilities()) echo '<a href="'.$_selection->getProductUrl().'" target="_blank">'; ?>
<?php echo $this->getSelectionQtyTitlePrice($_selection) ?>
<?php if ($_selection->getVisibleInSiteVisibilities()) echo '</a>'; ?>
</label></span>

I've tried $_selection->getVisibleIn SiteVisibilities() and that provides me with a boolean "false" regardless of how the visibility is set.

I tried $_selection->isVisibleInSiteVisibility() and that returns an array which seems to be the same for all products regardless of how the visibility is set as well.

Is there a simple way to find out if a product is set to be visible (or rather not set to "Not Visible Individually"?)

1

Have a look at the Mage_Catalog_Helper_Product function canShow. This function is used by the product controller when checking to see if a product can be shown. It uses the functions isVisibleInCatalog and isVisibleInSiteVisibility

public function canShow($product, $where = 'catalog')
{
    if (is_int($product)) {
        $product = Mage::getModel('catalog/product')->load($product);
    }

    /* @var $product Mage_Catalog_Model_Product */

    if (!$product->getId()) {
        return false;
    }

    return $product->isVisibleInCatalog() && $product->isVisibleInSiteVisibility();
}
  • Thanks, @David. I found my mistake in the code but I'll give this a shot sometime. I'm interested to see how your approach works out and like the fact that it takes both functions. – Greg Nickoloff May 2 '14 at 13:18
1

Apparently I had confused $_selection->isVisibleInSiteVisibility() and $_product->isVisibleInSiteVisibility() while working thru it.

This revision works as expected:

<span class="label">
  <label for="bundle-option-<?php echo $_option->getId() ?>-<?php echo $_selection->getSelectionId() ?>">  
    <?php if($_product->isVisibleInSiteVisibility()) echo '<a href="'.$_selection->getProductUrl().'" target="_blank">'; ?>  
    <?php echo $this->getSelectionQtyTitlePrice($_selection) ?>
    <?php if ($_product->isVisibleInSiteVisibility()) echo '</a>'; ?>
</label>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.