1
$batt_pack = Mage::getModel('catalog/product')->getCollection();
$batt_pack->addFieldToFilter('product_type',
        array(
            'like' => Mage::getResourceModel('catalog/product')
                        ->getAttribute('product_type')
                        ->getSource()
                        ->getOptionId('Battery Pack')
            )

although I used "like" it shows me only the ones that has just the product type of Battery pack it doesn't show me the ones has battery pack and some thing else how can I do that?

  ->getOptionId('Battery Pack%')

this one also didn't work I know it is so wrong but I guess I should do something like this

1
  • I found my solution! it was easy! I added % in the end of it
    – Nickool
    Jul 2, 2014 at 21:26

1 Answer 1

1

It was easier than I thought! I should have the % in the end of my string like this:

$batt_pack->addFieldToFilter('product_type',
        array(
            'like' => Mage::getResourceModel('catalog/product')
                        ->getAttribute('product_type')
                        ->getSource()
                        ->getOptionId('Battery Pack').'%'
            )
        );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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