1

I have two types of products (Product Type A (available for sale) and Product Type B (not available for sale)) and I created an attribute for each to differentiate.

I am trying to write a conditional in price.html to exclude the price and add to cart button on the catalog pages.

I have the following code that's working fine on the product page, but it's not working on the catalog page. Don't think it's picking up product attributes. Any help is much appreciated!

<?php $product_type = $_product->getAttributeText('product_type'); ?>
<?
if ($product_type == "Product Type A") {
    do something;
} else {
    do something else";
}
?>
3

For it to be available on the catalog page, you will need to set the used_in_product_listing value to 1. This can be done in the admin interface (the "Used in Product Listing" dropdown) or inside an update script:

$installer = Mage::getResourceModel('catalog/setup','catalog_setup');
$installer->startSetup();

$installer->updateAttribute(
    'catalog_product',
    'product_type',
    'used_in_product_listing',
    1
);

$installer->endSetup();

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.