0

I need to use grouped products because the products are vehicles and they have lots of sub models.

For example Citroen Berlingo (grouped product) has sub models like:

  1. panel van
  2. crew cab
  3. 8 seater

    • However, I find that the default grouped product page is not suitable for this purpose (the table with a list of names and quantity boxes). What want to do is show the different models in a grid/list looking the same as a category page.

I have not tried anything much yet, can't seem to locate any extensions that do this - this guy comes a little close with his question How to display simple product descriptions on a grouped product page? but I really want to show a grid - I am not a coder but I know how to edit stuff in magento code. So maybe what I want is something in the view.phtml... IF its a grouped product show the simple products as a grid (perhaps using some code from list.phtml) ? -

  • in view.phtml you can present the simple products of the group in anyway that you want, you just need to extract the child product data you need and then format your html to display the data the way you want it. – paj Sep 28 '15 at 8:45
  • Thanks do you have an example? Ideally I want the description of the grouped product at the top and then just a grid of the products available (looking exactly like a category page really),.. – b_uk_happy Sep 28 '15 at 8:59
  • I can't show you an example as I don't know exactly what you require. The solution will require some programming skills and perhaps a custom module that extracts the child product data you need for your custom template. As you also need to change the way the child data is constructed and displayed in view.phtml – paj Sep 28 '15 at 9:05
0

The example below describes how to create a simple extension for this purpose. First, you need to add the init file for you extension. The path is app/etc/modules/Atwix_Cmsattr.xml . The file’s content is:

<config>
    <modules>
        <Atwix_Cmsattr>
            <active>true</active>
            <codePool>local</codePool>
        </Atwix_Cmsattr>
    </modules>
</config>

The extension contains one block class and one model, therefore the config file, which you should have by the following path: app/code/local/Atwix/Cmsattr/etc/config.xml, is pretty simple and consists of a few records:

<config>
    <modules>
        <Atwix_Cmsattr>
            <version>0.1.0</version>
        </Atwix_Cmsattr>
    </modules>
    <global>
        <blocks>
            <atwix_cmsattr>
                <class>Atwix_Cmsattr_Block</class>
            </atwix_cmsattr>
        </blocks>
        <models>
            <atwix_cmsattr>
                <class>Atwix_Cmsattr_Model</class>
            </atwix_cmsattr>
        </models>
    </global>
</config>

After that, create the block class app/code/local/Atwix/Cmsattr/Block/List.php:

<?php
class Atwix_Cmsattr_Block_List extends Mage_Catalog_Block_Product_Abstract
{
    protected $_itemCollection = null;

    public function getItems()
    {
        $color = $this->getColor();
        if (!$color)
            return false;
        if (is_null($this->_itemCollection)) {
            $this->_itemCollection = Mage::getModel('atwix_cmsattr/products')->getItemsCollection($color);
        }

        return $this->_itemCollection;
    }
}

and the model class app/code/local/Atwix/Cmsattr/Model/Products.php:

<?php
class Atwix_Cmsattr_Model_Products extends Mage_Catalog_Model_Product
{
    public function getItemsCollection($valueId)
    {
        $collection = $this->getCollection()
            ->addAttributeToSelect('*')
            ->addAttributeToFilter('color', array('eq' => $valueId));
        Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection);
        return $collection;
    }
}

The next file is the most personal thing. You need the template file with your own mockup corresponding to your design. Here is an example for a simple list (app/design/frontend/base/default/template/atwix/cmsattr/list.phtml):

<?php $_items = $this->getItems() ?>
<div class="block">
    <div class="block-title">
        <strong><span><?php echo $this->__('Red Products') ?></span></strong>
    </div>
    <div class="block-content">
        <ol class="mini-products-list">
        <?php foreach ($_items as $_item): ?>
            <li class="item">
                <div class="product">
                    <a href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_item->getName()) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(50) ?>" width="50" height="50" alt="<?php echo $this->htmlEscape($_item->getName()) ?>" /></a>
                    <div class="product-details">
                        <p class="product-name"><a href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->htmlEscape($_item->getName()) ?></a></p>
                        <?php echo $this->getPriceHtml($_item, true) ?>
                        <?php if ($this->helper('wishlist')->isAllow()) : ?>
                        <a href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a>
                        <?php endif; ?>
                    </div>
                </div>
            </li>
        <?php endforeach; ?>
        </ol>
    </div>
</div>

The last created a cms page and included code like this

{{block type="atwix_cmsattr/list" name="cmsattr" template="atwix/cmsattr/list.phtml" color="26"}}

Using the methods similar to those described above I was able to fix it. Source for answer: http://www.atwix.com/magento/products-list-cms/

  • Yes your link answers your own question. But a link only answer treat as a bad answer here, because once the link dead, your answer become useless. So please put a short description of how the link really worked in your case – Rajeev K Tomy Oct 1 '15 at 1:49

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.