Skip to content

Instantly share code, notes, and snippets.

@evgv
Created September 22, 2016 15:46
Show Gist options
  • Save evgv/37383ae61635ccc1074f6134e3078d5b to your computer and use it in GitHub Desktop.
Save evgv/37383ae61635ccc1074f6134e3078d5b to your computer and use it in GitHub Desktop.
Magento. Check if product has custom options and get product types.

Check if product has custom options

For simple and conigurable product types get true/false has options return 1 or 0:

  <?php if ( $_product->getData('has_options') ): ?>
    <!-- do something -->
  <?php endif; ?>

For flat category data option enabled

    $opts = Mage::getSingleton('catalog/product_option')->getProductOptionCollection($_product);
    $optsSize = $opts->getSize();
    
    if ( $optsSize ) {
        ... // go go go
    }

Get product type:

  <?php if (($_product->getTypeID() == 'simple') ): ?>
    <!-- do something -->
  <?php endif; ?>
  
  /**
   * Product types: simple, sonfigurable, grouped, bundle, virtual, downloadable
   */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment