0

I'm at a bit of a loss on this one. I'm using the AheadWorks blog extension to add event posts for the current calendar year to my page. The extension also creates a feed of these posts, which I am feeding to Google Calendar. It is because of this that I use the dates of the events as the created dates, so they feed correctly to the Google Calendar. However, I can't figure out how to get Magento to display all posts; it only dislpays those with created dates from either the current day or sooner. I understand this is the default; how can I work around it so that all posts regardless of the created_time show?

I've seen several suggestions about changing the store time, and some that mention editing the created.php file, but I'm really not sure where to begin?

Could someone please give me an idea of what needs to be done?

Here's the app/code/community/AW/Blog/Block/Blog.php:

<?php
/**
 * aheadWorks Co.
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://ecommerce.aheadworks.com/AW-LICENSE.txt
 *
 * =================================================================
 *                 MAGENTO EDITION USAGE NOTICE
 * =================================================================
 * This software is designed to work with Magento community edition and
 * its use on an edition other than specified is prohibited. aheadWorks does     not
 * provide extension support in case of incorrect edition use.
 * =================================================================
 *
 * @category   AW
 * @package    AW_Blog
 * @version    1.3.4
 * @copyright  Copyright (c) 2010-2012 aheadWorks Co.   (http://www.aheadworks.com)
 * @license    http://ecommerce.aheadworks.com/AW-LICENSE.txt
 */


class AW_Blog_Block_Blog extends AW_Blog_Block_Abstract
{
    public function getPosts()
    {
        $collection = parent::_prepareCollection();
        $tag = $this->getRequest()->getParam('tag');
        if ($tag) {
            $collection->addTagFilter(urldecode($tag));
        }
        parent::_processCollection($collection);
        return $collection;
    }

    protected function _prepareLayout()
    {
        if ($this->isBlogPage() && ($breadcrumbs = $this->getCrumbs())) {
            parent::_prepareMetaData(self::$_helper);
            $tag = $this->getRequest()->getParam('tag', false);
            if ($tag) {
                $tag = urldecode($tag);
                $breadcrumbs->addCrumb(
                    'blog',
                    array(
                        'label' => self::$_helper->getTitle(),
                        'title' => $this->__('Return to ' . self::$_helper-    >getTitle()),
                        'link'  => $this->getBlogUrl(),
                    )
                );
                $breadcrumbs->addCrumb(
                    'blog_tag',
                    array(
                        'label' => $this->__('Tagged with "%s"',     self::$_helper->convertSlashes($tag)),
                        'title' => $this->__('Tagged with "%s"', $tag),
                    )
                );
            } else {
                $breadcrumbs->addCrumb('blog', array('label' =>     self::$_helper->getTitle()));
            }
        }
    }
}

Here's the app/design/frontend/[theme]/[theme]/template/aw_blog/blog.phtml:

<?php
/**
 * aheadWorks Co.
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://ecommerce.aheadworks.com/AW-LICENSE.txt
 *
 * =================================================================
 *                 MAGENTO EDITION USAGE NOTICE
 * =================================================================
 * This software is designed to work with Magento community edition and
 * its use on an edition other than specified is prohibited. aheadWorks does  not
 * provide extension support in case of incorrect edition use.
 * =================================================================
 *
 * @category   AW
 * @package    AW_Blog
 * @version    1.3.4
 * @copyright  Copyright (c) 2010-2012 aheadWorks Co.   (http://www.aheadworks.com)
 * @license    http://ecommerce.aheadworks.com/AW-LICENSE.txt
 */
?><?php $posts = $this->getPosts(); ?>
<div id="messages_product_view">
    <?php Mage::app()->getLayout()->getMessagesBlock()->setMessages(Mage::getSingleton('customer/session')->getMessages(true)); ?>
    <?php echo Mage::app()->getLayout()->getMessagesBlock()->getGroupedHtml(); ?>
</div>

<?php echo $this->getChildHtml('aw_blog_comments_toolbar'); ?>

<?php foreach ($posts as $post): ?>

    <div class="postWrapper">
        <div class="postTitle">
            <h2><a href="<?php echo $post->getAddress(); ?>" ><?php echo $post->getTitle(); ?></a></h2>
            <h3><?php echo $post->getCreatedTime(); ?></h3>
        </div>
        <div class="postContent">
            <?php echo $post->getPostContent(); ?>
        </div>

        <?php echo $this->getBookmarkHtml($post) ?>
        <div class="tags"><?php echo $this->getTagsHtml($post) ?></div>
        <div class="postDetails">
            <?php if ($this->getCommentsEnabled()): ?>
                <?php echo $post->getCommentCount(); ?> <a href="<?php echo $post->getAddress(); ?>#commentBox" > <?php echo Mage::helper('blog')->__('Comments'); ?></a> |
            <?php endif; ?>
            <?php $postCats = $post->getCats(); ?>
            <?php if (!empty($postCats)): ?>
                <?php echo Mage::helper('blog')->__('Posted in'); ?>
                <?php foreach ($postCats as $data): ?>
                    <a href="<?php echo $data['url']; ?>"><?php echo $data['title']; ?></a>
                <?php endforeach; ?>
            <?php else: ?>
                <?php echo Mage::helper('blog')->__('Posted'); ?>
            <?php endif; ?><?php echo $this->__("By"); ?> <?php echo $post->getUser(); ?></div>
    </div>

<?php endforeach; ?>
<?php echo $this->getChildHtml('aw_blog_comments_toolbar'); ?>
4
  • Your first course of action, is a support ticket to AheadWorks. They do listen to feedback for new features, especially one of there flagship extensions.
    – user4351
    Feb 27, 2015 at 18:58
  • Way ahead of you! I am on the ball there:) Just no reply yet after a week. Feb 27, 2015 at 19:46
  • Oh wow, not my experience. But ya know, can always nudge it ahead on twitter ;).
    – user4351
    Feb 27, 2015 at 19:51
  • Do you sell tickets for these events? If so, there's this and this. If it's just for generating content, I can see why it's not something people have thought about adding to Magento.
    – user4351
    Feb 27, 2015 at 21:49

1 Answer 1

0

This block class isn't doing much of preparing the collection. You can see that it is done in the parent. If you look at your first file, you see that AW_Blog_Block_Blog extends AW_Blog_Block_Abstract. If you open up the file for this class in

app/code/community/AW/Blog/Block/Abstract.php

You'll find this method:

protected function _prepareCollection()
{
    if (!$this->getData('cached_collection')) {

        $collection = Mage::getModel('blog/blog')->getCollection()
            ->addPresentFilter()
            ->addEnableFilter(AW_Blog_Model_Status::STATUS_ENABLED)
            ->addStoreFilter()
            ->joinComments()
            ->setOrder('created_time', 'desc');

        $collection->setPageSize((int)self::$_helper->postsPerPage());

        $this->setData('cached_collection', $collection);
    }
    return $this->getData('cached_collection');
}

notice the line ->addPresentFilter()? The code for that method can be found in

app/code/community/AW/Blog/Model/Mysql4/Blog/Collection.php

public function addPresentFilter()
{
    $this->getSelect()->where('main_table.created_time<=?', now());
    return $this;
}

So this is where the filter is being applied. You should be fine by just commenting the call to this method (don't change the code in this method, as it could be used elsewhere). So your _prepareCollection() method should look like this in the abstract class:

protected function _prepareCollection()
{
    if (!$this->getData('cached_collection')) {

        $collection = Mage::getModel('blog/blog')->getCollection()
            //->addPresentFilter()
            ->addEnableFilter(AW_Blog_Model_Status::STATUS_ENABLED)
            ->addStoreFilter()
            ->joinComments()
            ->setOrder('created_time', 'desc');

        $collection->setPageSize((int)self::$_helper->postsPerPage());

        $this->setData('cached_collection', $collection);
    }
    return $this->getData('cached_collection');
}

This should show ALL your posts. No date filter.

2
  • You completed the puzzle! Thank you for getting me there! Feb 27, 2015 at 22:11
  • You were nearly there yourself I noticed as soon as I had posted my answer. Welcome to magento.stackexchange!
    – Vic
    Feb 27, 2015 at 22:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.