0
我正在嘗試顯示與fishpig中的博客相關的產品數量。獲取Fishpig博客中的相關產品數量
我想下面的方法,但它返回空值。
$post->getAssociatedProducts();
功能
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;
}
請問這個產品寄回算?
感謝@Ben它的工作! :) –