0
我無法濾除與posts.phtml塊中的產品相關聯的關聯類別帖子(使用Fishpig)。我試着用以下解決方案來獲得職位:如何在Magento產品頁面上顯示關聯的WordPress類別的帖子(Fishpig集成)?
Fishpig Wordpress Magento Post issue
像這樣:
$categoryId = Mage::registry('wordpress_category')->getId();
$recentPostCollection = Mage::getModel('wordpress/post')->getCollection()
->addIsPublishedFilter()
->addCategoryIdFilter($categoryId)
->setOrder('post_date', 'desc')
->setPageSize($numPostsToShow)
;
然後修改原有的相關文章區塊:
<?php //$posts = $this->getPosts() ?>
<?php $posts = $recentPostCollection; ?>
<?php if (count($posts) > 0): ?>
<div class="block block-blog block-recent-posts">
<?php if ($title = $this->getTitle()): ?>
<div class="block-title">
<strong><span><?php echo $this->__($title) ?></span></strong>
</div>
<?php endif; ?>
<div class="block-content">
<ul id="<?php echo $this->getListId() ?>">
<?php foreach($posts as $post): ?>
<li class="item">
<?php $image = $post->getFeaturedImage(); ?>
<img src="<?php echo $this->htmlEscape($image->getAvailableImage()) ?>" ?>
</li>
<?php endforeach; ?>
</ul>
<script type="text/javascript">decorateList('<?php echo $this->getListId() ?>')</script>
</div>
</div>
<?php endif; ?>
的,那麼,那不行。當我將一個靜態數字放入$ categoryID時,我至少可以將數據放入$ recentPostCollection中,但循環不能用於該數據結構......任何幫助都將非常棒!謝謝。