Magento - Shop by Brand
There are several Magento extensions that offer shop by brand functionality, which is a great feature for any eCommerce site. What most people don't realise is that Attribute Splash Pages is a Shop-By-Brand extension with a key difference. While most extensions allow you to choose your brand attribute and then shop by that, Attribute Splash Pages allows you to shop by any attribute you have and doesn't limit you to just 1! Using Attribute Splash Pages you can have shop by brand, shop by colour or shop by any attribute you create in your Magento eCommerce store.
Attribute Splash Pages is a completely free extension and can be installed automatically via Magento Connect. To do this, click here to get the extension key. You can then use this to automatically install the extension via your Magento Downloader.
To install the extension manually, use the link above to download the extension files and merge them with your site using FTP/SFTP.
After installing the extension, ensure that you refresh your Magento cache and log out and log back in to your Magento Admin to complete the process.
Loading a Splash Page model is quite easy and there are many different ways to accomplish it. The following code illustrates 2 methods to load a Splash Page and then shows how to retrieve a collection of products that belong to the Splash Page.
<?php //Load a Splash Page by it's ID $splashPage = Mage::getModel('attributeSplash/page')->load($splashPageId); // Load a Splash Page by an option ID $splashPage = Mage::getModel('attributeSplash/page')->loadByOptionId($optionId); // Retrieve a collection of products $productCollection = $splashPage->getProductCollection() ?>
You can also load a Splash Page for a particular product and attribute code. This is useful to add a link to the Splash Page on the product page.
<?php // Load a Splash Page for the product's value in the brand attribute $splashPage = Mage::helper('attributeSplash')->getProductSplashPage($_product, 'brand'); ?> <?php if ($splashPage !== false): ?> <a href="<?php echo $splashPage->getUrl() ?>"> <span><?php echo $_product->getAttributeText('brand') ?></span> </a> <?php endif; ?>
It's sometimes useful to get a list of all Splash Page's for a certain attribute. As an example, you may want to list all brands to create a brand navigation.
<?php $splashGroup = Mage::getModel('attributeSplash/group')->load($splashGroupId) ?> <?php if ($splashGroup->getId()): ?> <?php $splashHelper = Mage::helper('attributeSplash/image') ?> <?php $splashPages = $splashGroup->getSplashPages() ?> <?php if (count($splashPages) > 0): ?> <ul> <?php foreach($splashPages as $splashPage): ?> <?php $splashHelper->init($splashPage, 'thumbnail') ?> <li class="item"> <a href="<?php echo $splashPage->getUrl() ?>" title="<?php echo $this->escapeHtml($splashPage->getName()) ?>"> <img src="<?php echo $splashHelper->resize(100, 100) ?>" alt="<?php echo $this->escapeHtml($splashPage->getName()) ?>" /> </a> </li> <?php endforeach; ?> </ul> <?php endif; ?> <?php endif; ?>