JM Product List Mod Error

on the CMS page (for the home page) we simply have the one line:

{{block type="joomlart_jmproducts/list" name="home.jmproducts.list" }}

We have checked the settings for the mod and it is enabled and installed properly. We are trying to use this with the JM Purity template.

it generates the following error:

——— from error report ————--
a:2:{i:0;s:122:"Notice: Undefined index: show in /home/dttstore/public_html/app/code/local/JoomlArt/JmProducts/Block/List.php on line 43";i:1;s:3075:"#0 /home/dttstore/public_html/app/code/local/JoomlArt/JmProducts/Block/List.php(43): mageCoreErrorHandler(8, ‘Undefined index…’, ‘/home/dttstore/…’, 43, Array)
#1 /home/dttstore/public_html/app/code/core/Mage/Core/Block/Abstract.php(643): JoomlArt_JmProducts_Block_List->_toHtml()
#2 /home/dttstore/public_html/app/code/core/Mage/Core/Model/Email/Template/Filter.php(74): Mage_Core_Block_Abstract->toHtml()
#3 /home/dttstore/public_html/lib/Varien/Filter/Template.php(128): Mage_Core_Model_Email_Template_Filter->blockDirective(Array)
#4 /home/dttstore/public_html/app/code/core/Mage/Cms/Block/Page.php(80): Varien_Filter_Template->filter(Array, Array)
#5 /home/dttstore/public_html/app/code/core/Mage/Core/Block/Abstract.php(643): Mage_Cms_Block_Page->_toHtml(‘{{block type="j…’)
#6 /home/dttstore/public_html/app/code/core/Mage/Core/Block/Text/List.php(43): Mage_Core_Block_Abstract->toHtml()
#7 /home/dttstore/public_html/app/code/core/Mage/Core/Block/Abstract.php(643): Mage_Core_Block_Text_List->_toHtml()
#8 /home/dttstore/public_html/app/code/core/Mage/Core/Block/Abstract.php(503): Mage_Core_Block_Abstract->toHtml()
#9 /home/dttstore/public_html/app/code/core/Mage/Core/Block/Abstract.php(454): Mage_Core_Block_Abstract->_getChildHtml()
#10 /home/dttstore/public_html/app/design/frontend/default/ntsecurity.com/template/page/2columns-right.phtml(69): Mage_Core_Block_Abstract->getChildHtml(‘content’, true)
#11 /home/dttstore/public_html/app/code/core/Mage/Core/Block/Template.php(144): include(‘/home/dttstore/…’)
#12 /home/dttstore/public_html/app/code/core/Mage/Core/Block/Template.php(176): Mage_Core_Block_Template->fetchView(‘content’)
#13 /home/dttstore/public_html/app/code/core/Mage/Core/Block/Template.php(193): Mage_Core_Block_Template->renderView(‘frontend/defaul…’)
#14 /home/dttstore/public_html/app/code/core/Mage/Core/Block/Abstract.php(643): Mage_Core_Block_Template->_toHtml()
#15 /home/dttstore/public_html/app/code/core/Mage/Core/Model/Layout.php(525): Mage_Core_Block_Abstract->toHtml()
#16 /home/dttstore/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(339): Mage_Core_Model_Layout->getOutput()
#17 /home/dttstore/public_html/app/code/core/Mage/Cms/Helper/Page.php(86): Mage_Core_Controller_Varien_Action->renderLayout()
#18 /home/dttstore/public_html/app/code/core/Mage/Cms/controllers/IndexController.php(32): Mage_Cms_Helper_Page->renderPage()
#19 /home/dttstore/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(367): Mage_Cms_IndexController->indexAction(Object(Mage_Cms_IndexController), ‘home’)
#20 /home/dttstore/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(163): Mage_Core_Controller_Varien_Action->dispatch()
#21 /home/dttstore/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(‘index’)
#22 /home/dttstore/public_html/app/Mage.php(457): Mage_Core_Controller_Varien_Front->dispatch(Object(Mage_Core_Controller_Request_Http ))
#23 /home/ntsecuri/public_html/index.php(41): Mage::run()
#24 {main}";}

8 answers

Profile photo of JA Developer 0.00 $tone April 27, 2009
Public

Hi,

we have fixed this issue and update to the lastest verion.
To solve this issue, please open app\code\local\JoomlArt\JmProducts\Block\List.php file, at about line 43, find following code:

Code:

if(!$this->_config['show']) return;

and change to:

Code:

if(!isset($this->_config['show']) || !$this->_config['show']) return;
#1
Profile photo of Brian Reed 0.00 $tone April 27, 2009
Public

Ok, now another error has popped up:

Notice: Undefined variable: listall in /home/fortiwal/public_html/app/code/local/JoomlArt/JmProducts/Block/List.php on line 45
Trace:
#0 /home/fortiwal/public_html/app/code/local/JoomlArt/JmProducts/Block/List.php(45): mageCoreErrorHandler(8, ‘Undefined varia…’, ‘/home/fortiwal/…’, 45, Array)
#1 /home/fortiwal/public_html/app/code/core/Mage/Core/Block/Abstract.php(643): JoomlArt_JmProducts_Block_List->_toHtml()
#2 /home/fortiwal/public_html/app/code/core/Mage/Core/Model/Email/Template/Filter.php(74): Mage_Core_Block_Abstract->toHtml()
#3 /home/fortiwal/public_html/lib/Varien/Filter/Template.php(128): Mage_Core_Model_Email_Template_Filter->blockDirective(Array)
#4 /home/fortiwal/public_html/app/code/core/Mage/Cms/Block/Page.php(80): Varien_Filter_Template->filter(Array, Array)
#5 /home/fortiwal/public_html/app/code/core/Mage/Core/Block/Abstract.php(643): Mage_Cms_Block_Page->_toHtml(‘

#2
Profile photo of JA Developer 0.00 $tone April 28, 2009
Public

Hi fortiwall,

Current your server turn notices on.It is cause you see this issue. Please try to send me your FTP account via PM, i will help you to fix issues.

#3
Profile photo of Darrell Francis 0.00 $tone July 30, 2009
Public

Hi There, i’m having a similar problem with JM Product list
on the CMS page (for the home page) i have the following one line of code:

{{block type="joomlart_jmproducts/list" name="home.jmproducts.list" }}

i’ve also tried this code:

{{block type="joomlart_jmproducts/list" title="Latest product" name="home.jmproducts.list" mode="latest"}}

i’ve trying place it directly into a managed page and also a static block
but both methods return the same error.

I have checked the settings for the mod and it is enabled and installed properly. i am trying to use this with the JM Tube template.

it generates the following error:

Cannot send headers; headers already sent in /home/theipode/public_html/app/code/local/JoomlArt/JmProducts/Block/List.php, line 2
Trace:
#0 /home/theipode/public_html/lib/Zend/Controller/Response/Abstract.php(147): Zend_Controller_Response_Abstract->canSendHeaders(true)
#1 /home/theipode/public_html/app/code/core/Mage/Adminhtml/Controller/Action.php(340): Zend_Controller_Response_Abstract->setRedirect(‘http://www.thei…&#8217😉
#2 /home/theipode/public_html/app/code/community/MageParts/CmsGui/controllers/Adminhtml/PageController.php(287): Mage_Adminhtml_Controller_Action->_redirect(‘*/*/edit’, Array)
#3 /home/theipode/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(376): MageParts_CmsGui_Adminhtml_PageController->saveAction()
#4 /home/theipode/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(248): Mage_Core_Controller_Varien_Action->dispatch(‘save’)
#5 /home/theipode/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http) )
#6 /home/theipode/public_html/app/Mage.php(459): Mage_Core_Controller_Varien_Front->dispatch()
#7 /home/theipode/public_html/index.php(65): Mage::run()
#8 {main}

Cheers

#6
Profile photo of JA Developer 0.00 $tone July 31, 2009
Public

Hi mac4media

Please open app\code\local\JoomlArt\JmProducts\Block\List.php file, at the top of page, please delete the first empty line.

If not, please send me your live url, admin account, i will help you to solve this issue.

Also, you can copy my code and replace into List.php file.

Code:

<?php
/**
* Jmtabs View block
*
* @codepool   Local
* @category   JoomlArt
* @package    JoomlArt_Jmtabs
* @module     Jmtabs
*/

class JoomlArt_JmProducts_Block_List extends Mage_Catalog_Block_Product_List 
{
	var $_config = array();
	
	public function __construct($attributes = array()){
		$helper =  Mage::helper('joomlart_jmproducts/data');
		
		$this->_config['show'] = $helper->get('show', $attributes);
		if(!$this->_config['show']) return;
		
		parent::__construct();
	
		$this->_config['mode'] = $helper->get('mode', $attributes);
		$this->_config['title'] = $helper->get('title', $attributes);
		
		$this->_config['qty'] = $helper->get('quanlity', $attributes);
		$this->_config['qty'] = $this->_config['qty']>0?$this->_config['qty']:5;	
			
		$this->_config['perrow'] = $helper->get('perrow', $attributes);
		$this->_config['perrow'] = $this->_config['perrow']>0?$this->_config['perrow']:3;	
		
		$this->_config['template'] = $helper->get('template', $attributes);
		/*$this->_config['attributename'] = $helper->get('attributename', $attributes);
		$this->_config['attributevalue'] = $helper->get('attributevalue', $attributes);*/
				
		$this->setProductCollection($this->getCategory());
	}
		
	function _toHtml() {					
		if(!$this->_config['show']) return;

		$listall = $this->getListProducts();
		
		$this->assign('listall', $listall);
		$this->assign('config', $this->_config);
				
		if(!isset($this->_config['template']) || $this->_config['template']==''){
			$this->_config['template'] = 'joomlart/jmproducts/list.phtml';
		}
		
		$this->setTemplate($this->_config['template']);
		
		if($listall && $listall->count()>0){
			Mage::getModel('review/review')->appendSummary($listall);
		}
		
        return parent::_toHtml();	
	}			
		
	function getListProducts(){
		$listall = null;
		switch ($this->_config['mode']){
			case 'latest':				
				$listall = $this->getListBestBuyProducts( 'updated_at', 'desc');				
				break;
			case 'feature':
				break;
			case 'best_buy':
				$listall = $this->getListBestBuyProducts();
				break;
			case 'most_viewed':
				$listall = $this->getListMostViewedProducts();
				break;
			case 'most_reviewed':
				$listall = $this->getListTopRatedProducts('reviews_count');
				break;
			case 'top_rated':
				$listall = $this->getListTopRatedProducts();
				break;	
			case 'attribute':			
				$listall = $this->getListFeaturedProduct();
				break;				
		}

		return $listall;
	}	
	
	function getListTopRatedProducts($orderfeild='rating_summary', $order='desc', $perPage=NULL, $currentPage=1){
		$list = null;
		if($perPage === NULL) $perPage	= (int) $this->_config['qty'];
		$storeId = Mage::app()->getStore()->getId();

        $entityCondition = '_reviewed_order_table.entity_id = e.entity_id';
		
		$products = Mage::getResourceModel('catalog/product_collection')
					->setStoreId($storeId)
					->addAttributeToSelect('*')
					->addStoreFilter($storeId);
					
		$products->getSelect()->joinLeft(
			                array('_reviewed_order_table'=>$products->getTable('review_entity_summary')),
			                		"_reviewed_order_table.store_id=$storeId AND _reviewed_order_table.entity_pk_value=e.entity_id",
			                array()
			            );
		$products->getSelect()->order("_reviewed_order_table.$orderfeild $order");	
        $products->getSelect()->group('e.entity_id');		
        		
		$products->setPageSize($perPage)->setCurPage($currentPage);
		
		$this->setProductCollection($products);
			
		if (($_products = $this->getProductCollection()) && $_products->getSize()){
			$list = $products;
		}	
		
		return $list;		
	}		
	
	function getListMostViewedProducts($perPage=NULL, $currentPage=1){									
		/* 
			Always set de $perPage, by template or by config 
			if $perPage eq 0 (zero) not limit the list
		*/
		if($perPage === NULL) $perPage	= (int) $this->_config['qty'];		
		/*
			Show all the product list in the current store			
		*/
		$storeId = Mage::app()->getStore()->getStoreId();
        $this->setStoreId($storeId);
       
        $this->_productCollection = Mage::getResourceModel('reports/product_collection');
        
		$this->_productCollection = $this->_productCollection->addViewsCount(); 
               
        $this->_productCollection = $this->_productCollection->addAttributeToSelect('*')
                        ->setStoreId($storeId)
                        ->addStoreFilter($storeId)
                        ->setPageSize($perPage);       
        return $this->_productCollection;	
	}
	
	function getListBestBuyProducts($fieldorder='ordered_qty', $order='desc', $product_ids='', $perPage=NULL, $currentPage=1){							
		$list = null;				
		/* 
			Always set de $perPage, by template or by config 
			if $perPage eq 0 (zero) not limit the list
		*/
		if($perPage === NULL) $perPage	= (int) $this->_config['qty'];
		/*
			Show all the product list in the current store
			order by ordered_qty, showing the bestsellers first
		*/
		$storeId = Mage::app()->getStore()->getId();
		$products = Mage::getResourceModel('catalog/product_collection')
					->setStoreId($storeId)
					->addAttributeToSelect('*')
					->addStoreFilter($storeId)
					->setOrder($fieldorder, $order);	
				
		if ($product_ids) {
			$products->getSelect()->where("e.entity_id in ($product_ids)");
					
		}

		/*
			Filter list of product showing only the active and 
			visible product
		*/
		Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
		Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);

		$products->setPageSize($perPage)->setCurPage($currentPage);
		
		$this->setProductCollection($products);
			
		if (($_products = $this->getProductCollection()) && $_products->getSize()){
			$list = $_products;
		}	
		
		return $list;
	}

	function getListFeaturedProduct(){

		$list = array();	
// instantiate database connection object
#
        
#
        $resource = Mage::getSingleton('core/resource');
#
        $read = $resource->getConnection('catalog_read');
#
        $categoryProductTable = $resource->getTableName('catalog/category_product');

#
        $productEntityIntTable = (string)Mage::getConfig()->getTablePrefix() . 'catalog_product_entity_int';
#
        $eavAttributeTable = $resource->getTableName('eav/attribute');
#
   
#
        // Query database for featured product
#		
        $select = $read->select('cp.product_id')
#
                       ->from(array('cp'=>$categoryProductTable))
#
                       ->join(array('pei'=>$productEntityIntTable), 'pei.entity_id=cp.product_id', array())
#
                       ->joinNatural(array('ea'=>$eavAttributeTable))
#
                       ->where("pei.value='1'")
#
                       ->where("ea.attribute_code='featured'");       
#
        $rows = $read->fetchAll($select);
#		

		$product_ids = array();
		if ($rows) {
			foreach ($rows as $row){
				$product_ids[] = $row['product_id'];
			}
			$product_ids = implode(',', $product_ids);
			$list = $this->getListBestBuyProducts( 'updated_at', 'desc', $product_ids);
		}		
				       
        return $list;
	}		
		
	function set($show=1, $mode='', $title='', $template='', $quanlity=9, $perrow=3){
		if(!$mode || !$show){
			return ;
		}		
		
		if($mode) $this->_config['mode'] = $mode;
		if($title) $this->_config['title'] = $title;
		if($template!='') 	$this->_config['template'] = $template;
		if($quanlity)		$this->_config['qty'] = $quanlity;
		if($perrow)		$this->_config['perrow'] = $perrow;
		//if($attributename)		$this->_config['attributename'] = $attributename;
		//if($attributevalue)		$this->_config['attributevalue'] = $attributevalue;		
	}
}
#7

This question is now closed

Written By

Comments