public function getCategoryString(Fishpig_Wordpress_Model_Post_Abstract $object, array $params = array()) { $html = array(); if (count($categories = $object->getParentCategories()) > 0) { foreach ($categories as $category) { $html[] = $this->_generateAnchor($category->getUrl(), $category->getName(), $params); } } return implode(', ', $html); }
/** * Retrieve a collection of products assocaited with the post * * @param Fishpig_Wordpress_Model_Post $post * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection */ public function getAssociatedProductsByPost(Fishpig_Wordpress_Model_Post_Abstract $post) { if (!$post instanceof Fishpig_Wordpress_Model_Post) { return false; } $associations = array_keys($this->getReverseAssociations('product/post', $post->getId())); foreach ($post->getParentCategories() as $category) { $associations = array_merge($associations, array_keys($this->getReverseAssociations('product/category', $category->getId()))); } $associations = array_unique($associations); if (count($associations) > 0) { $collection = Mage::getResourceModel('catalog/product_collection'); Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); $collection->addAttributeToFilter('status', 1); $collection->addAttributeToFilter('entity_id', array('in' => $associations)); return $collection; } return false; }