0
fishpigでブログに関連付けられている商品の数を表示しようとしています。Fishpigブログの関連商品を取得する
私は以下のメソッドを試していますが、null値が返されています。
public function getAssociatedProducts($post)
{
if ($post instanceof Fishpig_Wordpress_Model_Post) {
$productIds = $this->_getAssociatedWpEntityIds($post->getId(), 'product', 'post', 'post_id');
try {
foreach($post->getParentCategories() as $category) {
$productIds = array_merge($productIds, $this->_getAssociatedWpEntityIds($category->getId(), 'product', 'category', 'category_id'));
}
}
catch (Exception $e) {
$this->log($e->getMessage());
}
if (count($productIds) > 0) {
$collection = Mage::getResourceModel('catalog/product_collection');
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
$collection->addAttributeToFilter('status', 1);
$collection->addAttributeToFilter('entity_id', array('in' => $productIds));
return $collection;
}
}
return false;
}
$post->getAssociatedProducts();
機能は、本製品の数を返すのだろうか?
おかげで、それが働いた@Ben:
は延長の最新バージョンを使用してポストのために関連した製品を入手するには、次の使用します! :) –