【发布时间】:2017-08-17 12:25:01
【问题描述】:
这是我的疑问。我必须为 magento 主机上的每个 storeview 导出一个 XML 文件。此目录必须包含 storeview 提供的所有产品。我需要导出的信息至少是:SKU、名称、描述、图片 url、每个产品所属的类别和产品 URL。 我已经完成了逻辑,但是我在过滤产品时遇到了问题,我现在正在做的是:
public function getXmlForAllStores()
{
foreach ($this->_storeManagerInterface->getWebsites() as $site):{
foreach ($site->getGroups() as $store): {
$rootCategoryId = $store->getRootCategoryId();
$rootCategory = $this->_rootCategory->load($rootCategoryId);
$catIdArray = $this->toIntArray($rootCategory->getAllChildren(true));
foreach ($store->getStores() as $storeview):{$collection = $this->_categoryLayer
->setCurrentCategory($rootCategory)
->getProductCollection()
->addWebsiteFilter($site);
//get xml string
$xmlData= $this->toXml($collection, $store, $storeview);
$fileName = $storeview->getCode()."feed.xml";
echo "filename: ". $fileName. "<br>";
//make file
$this->makeFile($xmlData,$fileName);
}endforeach;
}endforeach;
}endforeach;
return "ok";
}
如您所见,我正在对最低范围进行迭代,以便为每个网站上包含的所有商店组中的所有商店视图获取不同的 xml 文件。但我找不到根据 storeview 检索数据的方法,比如名称、描述以及更关键的、根据 storeview 的产品 url。 setstoreid 过滤器不适用于我想要的。 任何帮助都会很棒,感谢阅读!
【问题讨论】: