Loading a product collection through multiple storesCreating a store for each country with multiple...

Is there a feather fall weight limit?

Do authors have to be politically correct in article-writing?

How old is the day of 24 equal hours?

Cookies - Should the toggles be on?

What would the chemical name be for C13H8Cl3NO

How does Leonard in "Memento" remember reading and writing?

Aligning symbols underneath each other neatly

What is the purpose of easy combat scenarios that don't need resource expenditure?

Removing disk while game is suspended

Has any human ever had the choice to leave Earth permanently?

SET NOCOUNT Error in handling SQL call after upgrade

Cat is tipping over bed-side lamps during the night

What are "industrial chops"?

Increment each digit in a number to form a new number

Does every functor from Set to Set preserve products?

What would be the rarity of this magic item(s)?

Can I make estimated tax payments instead of withholding from my paycheck?

What is the use of 'de' preposition in 'Yo voy *de* compras todos los sábados'

Why do neural networks need so many training examples to perform?

How can my powered armor quickly replace its ceramic plates?

In Linux what happens if 1000 files in a directory are moved to another location while another 300 files were added to the source directory?

A Missing Symbol for This Logo

Graph with overlapping labels

Why exactly do action photographers need high fps burst cameras?



Loading a product collection through multiple stores


Creating a store for each country with multiple languageHow to addFieldToFilter for attribute special_price with flat product tables?Storeswitcher (not storeview-switcher) - MultistoreMultiple Store - Add to cart - Much slower on secondary stores than primaryHow to get the URL for the B2C website/storeview from a B2B website/storeview/product-pageCreate categories through installerMagento create simple product from configurable for multiple stores not workingMagento rewrite Mage_Adminhtml_Block_Catalog_Product_GridAdding Child Data to the Product Flat IndexMagento1.9 Assign products to different categories for different storeviews













5















We've created an additional indexer that is started by using the backend indexer functions. We have flat tables enabled. We have multiple storeviews that correspond to different languages.



The following code is an excerpt from the indexer code.



public function rebuildIndex ($productIds) {
$stores = Mage::app()->getStores();
foreach ($stores AS $store) {
Mage::app()->setCurrentStore($store);
$products = Mage::getModel('catalog/product')
->getCollection()
->setStore($store)
->addAttributeToFilter('status', 1)
->addAttributeToFilter('visibility', array ('in' => array (Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_SEARCH, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)))
->addAttributeToSelect('*')
->setPageSize(1000)
->setCurPage(++$page);
}
}


The problem is that for the second and third store, the products loaded use the language of the first storeview.



We've tried finding out what the problem is. So far, we've seen that when using flat tables, the product flat tables created are these:




  • catalog_product_flat_1

  • catalog_product_flat_2

  • catalog_product_flat_3


The number at the end corresponds to the storeview (and therefor the language). However, in all cases, the generated SELECT statement selects from the first table, making the language of the products loaded in all 3 storeviews the language of the first storeview.



We can't disable flat tables (which we tried, and that fixes the problem). Is there any way to load the products for each of the storeviews?










share|improve this question

























  • Try adding addStoreFilter() to your product collection after you set the store. I've not seen setStore($store) used before, but I have seen setStoreId($store->getId()) - Not sure if there's gonna be a difference.

    – pspahn
    Aug 1 '14 at 18:05













  • Added setStoreId(...) followed by addStoreFilter() to the building of the collection. No change.

    – 0xCAFEBABE
    Aug 4 '14 at 6:14











  • @0xCAFEBABE were you able to solve this problem? If so, how?

    – 7ochem
    Mar 8 '16 at 13:41






  • 3





    We determined it to be a problem of the flat tables. We inserted a Mage::unregister('_resource_singleton/catalog/product_flat'); right before doing the collection gathering, so the indexing would work around the flat tables. It's usually executed from the command line anyway, so performance wasn't critical.

    – 0xCAFEBABE
    Mar 9 '16 at 8:03











  • @0xCAFEBABE, thanks, this solution works fine

    – Andy Webov
    Jul 6 '18 at 7:28
















5















We've created an additional indexer that is started by using the backend indexer functions. We have flat tables enabled. We have multiple storeviews that correspond to different languages.



The following code is an excerpt from the indexer code.



public function rebuildIndex ($productIds) {
$stores = Mage::app()->getStores();
foreach ($stores AS $store) {
Mage::app()->setCurrentStore($store);
$products = Mage::getModel('catalog/product')
->getCollection()
->setStore($store)
->addAttributeToFilter('status', 1)
->addAttributeToFilter('visibility', array ('in' => array (Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_SEARCH, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)))
->addAttributeToSelect('*')
->setPageSize(1000)
->setCurPage(++$page);
}
}


The problem is that for the second and third store, the products loaded use the language of the first storeview.



We've tried finding out what the problem is. So far, we've seen that when using flat tables, the product flat tables created are these:




  • catalog_product_flat_1

  • catalog_product_flat_2

  • catalog_product_flat_3


The number at the end corresponds to the storeview (and therefor the language). However, in all cases, the generated SELECT statement selects from the first table, making the language of the products loaded in all 3 storeviews the language of the first storeview.



We can't disable flat tables (which we tried, and that fixes the problem). Is there any way to load the products for each of the storeviews?










share|improve this question

























  • Try adding addStoreFilter() to your product collection after you set the store. I've not seen setStore($store) used before, but I have seen setStoreId($store->getId()) - Not sure if there's gonna be a difference.

    – pspahn
    Aug 1 '14 at 18:05













  • Added setStoreId(...) followed by addStoreFilter() to the building of the collection. No change.

    – 0xCAFEBABE
    Aug 4 '14 at 6:14











  • @0xCAFEBABE were you able to solve this problem? If so, how?

    – 7ochem
    Mar 8 '16 at 13:41






  • 3





    We determined it to be a problem of the flat tables. We inserted a Mage::unregister('_resource_singleton/catalog/product_flat'); right before doing the collection gathering, so the indexing would work around the flat tables. It's usually executed from the command line anyway, so performance wasn't critical.

    – 0xCAFEBABE
    Mar 9 '16 at 8:03











  • @0xCAFEBABE, thanks, this solution works fine

    – Andy Webov
    Jul 6 '18 at 7:28














5












5








5








We've created an additional indexer that is started by using the backend indexer functions. We have flat tables enabled. We have multiple storeviews that correspond to different languages.



The following code is an excerpt from the indexer code.



public function rebuildIndex ($productIds) {
$stores = Mage::app()->getStores();
foreach ($stores AS $store) {
Mage::app()->setCurrentStore($store);
$products = Mage::getModel('catalog/product')
->getCollection()
->setStore($store)
->addAttributeToFilter('status', 1)
->addAttributeToFilter('visibility', array ('in' => array (Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_SEARCH, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)))
->addAttributeToSelect('*')
->setPageSize(1000)
->setCurPage(++$page);
}
}


The problem is that for the second and third store, the products loaded use the language of the first storeview.



We've tried finding out what the problem is. So far, we've seen that when using flat tables, the product flat tables created are these:




  • catalog_product_flat_1

  • catalog_product_flat_2

  • catalog_product_flat_3


The number at the end corresponds to the storeview (and therefor the language). However, in all cases, the generated SELECT statement selects from the first table, making the language of the products loaded in all 3 storeviews the language of the first storeview.



We can't disable flat tables (which we tried, and that fixes the problem). Is there any way to load the products for each of the storeviews?










share|improve this question
















We've created an additional indexer that is started by using the backend indexer functions. We have flat tables enabled. We have multiple storeviews that correspond to different languages.



The following code is an excerpt from the indexer code.



public function rebuildIndex ($productIds) {
$stores = Mage::app()->getStores();
foreach ($stores AS $store) {
Mage::app()->setCurrentStore($store);
$products = Mage::getModel('catalog/product')
->getCollection()
->setStore($store)
->addAttributeToFilter('status', 1)
->addAttributeToFilter('visibility', array ('in' => array (Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_SEARCH, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)))
->addAttributeToSelect('*')
->setPageSize(1000)
->setCurPage(++$page);
}
}


The problem is that for the second and third store, the products loaded use the language of the first storeview.



We've tried finding out what the problem is. So far, we've seen that when using flat tables, the product flat tables created are these:




  • catalog_product_flat_1

  • catalog_product_flat_2

  • catalog_product_flat_3


The number at the end corresponds to the storeview (and therefor the language). However, in all cases, the generated SELECT statement selects from the first table, making the language of the products loaded in all 3 storeviews the language of the first storeview.



We can't disable flat tables (which we tried, and that fixes the problem). Is there any way to load the products for each of the storeviews?







magento-1.9 ce-1.9.0.1 flat-catalog






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 7 mins ago









mlunt

506




506










asked Aug 1 '14 at 13:18









0xCAFEBABE0xCAFEBABE

347113




347113













  • Try adding addStoreFilter() to your product collection after you set the store. I've not seen setStore($store) used before, but I have seen setStoreId($store->getId()) - Not sure if there's gonna be a difference.

    – pspahn
    Aug 1 '14 at 18:05













  • Added setStoreId(...) followed by addStoreFilter() to the building of the collection. No change.

    – 0xCAFEBABE
    Aug 4 '14 at 6:14











  • @0xCAFEBABE were you able to solve this problem? If so, how?

    – 7ochem
    Mar 8 '16 at 13:41






  • 3





    We determined it to be a problem of the flat tables. We inserted a Mage::unregister('_resource_singleton/catalog/product_flat'); right before doing the collection gathering, so the indexing would work around the flat tables. It's usually executed from the command line anyway, so performance wasn't critical.

    – 0xCAFEBABE
    Mar 9 '16 at 8:03











  • @0xCAFEBABE, thanks, this solution works fine

    – Andy Webov
    Jul 6 '18 at 7:28



















  • Try adding addStoreFilter() to your product collection after you set the store. I've not seen setStore($store) used before, but I have seen setStoreId($store->getId()) - Not sure if there's gonna be a difference.

    – pspahn
    Aug 1 '14 at 18:05













  • Added setStoreId(...) followed by addStoreFilter() to the building of the collection. No change.

    – 0xCAFEBABE
    Aug 4 '14 at 6:14











  • @0xCAFEBABE were you able to solve this problem? If so, how?

    – 7ochem
    Mar 8 '16 at 13:41






  • 3





    We determined it to be a problem of the flat tables. We inserted a Mage::unregister('_resource_singleton/catalog/product_flat'); right before doing the collection gathering, so the indexing would work around the flat tables. It's usually executed from the command line anyway, so performance wasn't critical.

    – 0xCAFEBABE
    Mar 9 '16 at 8:03











  • @0xCAFEBABE, thanks, this solution works fine

    – Andy Webov
    Jul 6 '18 at 7:28

















Try adding addStoreFilter() to your product collection after you set the store. I've not seen setStore($store) used before, but I have seen setStoreId($store->getId()) - Not sure if there's gonna be a difference.

– pspahn
Aug 1 '14 at 18:05







Try adding addStoreFilter() to your product collection after you set the store. I've not seen setStore($store) used before, but I have seen setStoreId($store->getId()) - Not sure if there's gonna be a difference.

– pspahn
Aug 1 '14 at 18:05















Added setStoreId(...) followed by addStoreFilter() to the building of the collection. No change.

– 0xCAFEBABE
Aug 4 '14 at 6:14





Added setStoreId(...) followed by addStoreFilter() to the building of the collection. No change.

– 0xCAFEBABE
Aug 4 '14 at 6:14













@0xCAFEBABE were you able to solve this problem? If so, how?

– 7ochem
Mar 8 '16 at 13:41





@0xCAFEBABE were you able to solve this problem? If so, how?

– 7ochem
Mar 8 '16 at 13:41




3




3





We determined it to be a problem of the flat tables. We inserted a Mage::unregister('_resource_singleton/catalog/product_flat'); right before doing the collection gathering, so the indexing would work around the flat tables. It's usually executed from the command line anyway, so performance wasn't critical.

– 0xCAFEBABE
Mar 9 '16 at 8:03





We determined it to be a problem of the flat tables. We inserted a Mage::unregister('_resource_singleton/catalog/product_flat'); right before doing the collection gathering, so the indexing would work around the flat tables. It's usually executed from the command line anyway, so performance wasn't critical.

– 0xCAFEBABE
Mar 9 '16 at 8:03













@0xCAFEBABE, thanks, this solution works fine

– Andy Webov
Jul 6 '18 at 7:28





@0xCAFEBABE, thanks, this solution works fine

– Andy Webov
Jul 6 '18 at 7:28










0






active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f30956%2floading-a-product-collection-through-multiple-stores%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f30956%2floading-a-product-collection-through-multiple-stores%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

迭戈·戈丁...

A phrase ”follow into" in a context The 2019 Stack Overflow Developer Survey Results Are...

1960s short story making fun of James Bond-style spy fiction The 2019 Stack Overflow Developer...