0

we are trying to send Abandoned cart email , we are getting errors as below :

Fatal error: Call to a member function getAllVisibleItems() on a non-object in line

<?php foreach($this->getOrder()->getAllVisibleItems() as $item): ?>    
<a href="<?php echo $item->getProduct()->getProductUrl() ?>"><?php echo $item->getName() ?></a>
<?php endforeach ?> 

I was working before one month, is any other code conflicting ? no log errors.

please give me some idea how i can solve this....

edit

protected function _getBaseProducts($parent)
    {
        $result = array();

        if ($parent->getOrder()) {
            foreach ($parent->getOrder()->getAllVisibleItems() as $item) {
                $result[] = $item->getProduct();
            }
        }

        if ($parent->getQuote() && count($result) == 0) {
            foreach ($parent->getQuote()->getAllVisibleItems() as $item) {
                $result[] = $item->getProduct();
            }
        }

        if ($parent->getCustomer() && count($result) == 0) {
            $orders = Mage::getModel('sales/order')
                ->getCollection()
                ->addAttributeToFilter('customer_id', $parent->getCustomer()->getId());
            foreach ($orders as $order) {
                foreach ($order->getAllVisibleItems() as $item) {
                    $result[] = $item->getProduct();
                }
            }
        }

        return $result;
    }

block

class Mirasvit_Email_Block_Cross extends Mage_Catalog_Block_Product_List
{
    public function _toHtml()
    {
        $this->setArea('frontend');
        $this->setTemplate('mst_email/cross.phtml');

        return $this->renderView();
    }

    public function getItems()
    {
        return $this->_productCollection;
    }
}
  • 1
    provide block type for your phtml – Murtuza Zabuawala Mar 21 '17 at 13:10
  • @MurtuzaZabuawala please check updated question – Baby in Magento Mar 21 '17 at 13:14
  • @BabyinMagento for better answer please add some more code/details - especially where/how you want to get the related order. – sv3n Jul 18 '17 at 16:58
1

If you call $this->getOrder() in your phtml file your block class Mirasvit_Email_Block_Cross has to have a getOrder() method (that is instance of Mage_Sales_Model_Order).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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