I have a problem getting the collection, I have two shops and each one have their sku prepended the shop code like EN_1234 FR_3513. I tried to get the collection like always:
$productCollection = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('entity_id')
->addAttributeToFilter('sku', array('like' => $shop.'%'));
But from a time to now it only works for one shop, EN. I saw the query and it's getting their data from catalog_product_flat_1
where all the products are from EN, but the products of FR are in catalog_product_flat_4
.
I tried to reindex by console and with the admin, but nothing. What can I do?
UPDATE
$shop = 'EN' or $shop = 'FR'
I see part of the problem is because I'm calling a script I have in the root of magento, If I use this same function inside the model all works.
$shop
variable valueMage::app()->setCurrentStore(0)
, works in part, because I would want to get the collection by website, but it's a good point, thanks