Is it possible in frontend magegento 1 to make such a table as in the admin panel?

enter image description here

Or is it better to do it in the phtml file using the js library?

Need advice, recommendation. Or a hint on how to implement (preferably) a standard grid

    1 answer 1

    There are several options:

    1. Create a separate фабрику - factory for the front-end module. Render on phtml, then get something like this grid.

    2. You can simply give access to the grid of products, and the creation of products to the admin panel, while creating an accountant, and not cutting the admin floor at the front. And just add some attribute for the user and filter on it.

    And so we will analyze in more detail the first random pseudo php language (I will not write fully functional just to show the logic)

    create an abstract class in the Block directory of our module, for example, the module will be Test_Frontgreed and, according to anology, we will implement it with adminhtml

    file Block / Abstract.php

     abstract class Test_Frontend_Block_Abstract extends Core_Block_Template { private $_collection = null; private $_columns = array(); public function __construct() { $this->setTemplate('your/greed.phtml'); } protected function _prepareCollection() { if($collection = $this->getData('collection') { // логика фильтрации коллекции $collection->load(); return $collection; } } public function getCollection() { if(is_null($this->_collection)) { $this->_collection = $this->_prepareCollection(); } return $this->_collection; } abstract public function prepareGrid(); //prepare grid protected function _addColumn($type,$key,$options) { $this->_columns[$key] = array( 'type' => $type; 'options' => $options; ); } public function getCollumn() { if(count($this->_columns) == 0) { $this->prepareGrid(); } return $this->_columns; } } 

    let's implement the base class extended from the previous one

     class Test_Frontend_Block_Product extends Test_Frontend_Block { protected function _prepareCollection() { $collection = Mage::getModel('catalog/product')->getCollection(); $this->setCollection(); parent:_prepareCollection(); } public function prepareGrid() { $this->_addColumn('text','entity_id',array('custom_options' => 'custom')); } } 

    well, the last to implement the template itself

     <?php foreach($this->getCollection() as $_product): ?> <tr> <?php foreach($this->getCollumn() as $_key => $_collumn): ?> <td><?php echo $_product->getData($_key) ?> </td> <?php endforeach; ?> <tr> <?php endforeach; ?> 

    Well, here is a simple example of the implementation of the factory, although the second option should be preferable.