I am having a problem with addAttributeToFilter() where it is not working as I expect.
$product = Mage::getModel('catalog/product');
...snip...
$simple_associated_collection = $product->getCollection()
->addAttributeToFilter('type_id', 'simple')
->addAttributeToFilter('sku',array('like'=>$configurable_product_sku.'_%'))
->load();
Passing in 4_% I expect to get
4_1
4_2
But I also get
42_1
420_1
The goal is to get a collection of simple products so that I can associate them with their configurable parent after an import.
How should I be using LIKE to get the same results I would in MySQL?
Magento was not at fault here,
_is a wildcard character.I used Nick’s comment to echo the sql which was what I expected.
Fixed: