I have a multiwebsite-setup. Site 1 is a normal webshop. Site 2 is a satellite page that links to site 1. So I would like to create a product collection from site 1 starting like this:
$products = $this->_collectionFactory->create();
The resulting SQL points to the site we are currently on (site 2):
SELECT 1 AS `status`, `e`.`entity_id`, `e`.`attribute_set_id`, `e`.`type_id`, `e`.`created_at`, `e`.`updated_at`, `e`.`sku` FROM `catalog_product_flat_2` AS `e`
As you can see the query points to catalog_product_flat_2. How can I create a collection specifically pointing to a specific website?
Setting store or website in the returned object does not have any effect:
$products = $this->_collectionFactory->create(); $products ->addAttributeToSelect('*') ->addStoreFilter(1) // does not work ->setStoreId(1) // does not work ->addWebsiteFilter(1) // does not work ->addAttributeToFilter('status', array('in' => $this->_productStatus->getVisibleStatusIds())) ->setVisibility($this->_productVisibility->getVisibleInSiteIds()) ->addAttributeToFilter('sku', array('in' => $skus)) ;
EDIT: This only fails when using catalog flat tables. Without them there is no issue.