Posts

Showing posts from February, 2015

How can I get the all attributes together in one page for the each of categories (layered navigation)

<?php //echo 'Rahul singh'; $layer = Mage::getModel("catalog/layer"); $category = Mage::getModel("catalog/category")->load(3); $layer->setCurrentCategory($category); $attributes = $layer->getFilterableAttributes(); foreach ($attributes as $attribute) { echo $attribute->getAttributeCode().'<br />'; if ($attribute->getAttributeCode() == 'price') { $filterBlockName = 'catalog/layer_filter_price'; } elseif ($attribute->getBackendType() == 'decimal') { $filterBlockName = 'catalog/layer_filter_decimal'; } else { $filterBlockName = 'catalog/layer_filter_attribute'; } $result = Mage::app()->getLayout()->createBlock($filterBlockName)->setLayer($layer)->setAttributeModel($attribute)->init(); foreach($result->getItems() as $option) { echo $opt...

How to get the product count from the url's for the manufacture

$products = Mage::getModel('catalog/category')->load(4324)    ->getProductCollection()    ->addAttributeToSelect('*')    ->addAttributeToFilter('manufacturer', array('eq' => 22)); echo count($products); $products_combined = Mage::getModel('catalog/category')->load($currentCategoryId)->getProductCollection()->addAttributeToSelect('*')->addAttributeToFilter('status', array('gt' => 0))->addAttributeToFilter('visibility', 4)->addAttributeToFilter('material', array('eq' => 64)); echo count($products_combined); /*for price range*/ $products_gt250 = Mage::getModel('catalog/category')->load($currentCategoryId)->getProductCollection()->addAttributeToSelect('*')->addAttributeToFilter('status', array('gt' => 0))->addAttributeToFilter('visibility', 4)->addFieldToFilter(array(array('attribute...

Magento Code Snippets

# Magento Code Snippets # ## Download extension manually using mage ## bash ./mage config-set preferred_state stable ./mage clear-cache ./mage sync ./mage download community Module_Name ## Reindex ## bash php -f shell/indexer.php reindexall <?php // clear cache Mage::app()->removeCache('catalog_rules_dirty'); // reindex prices Mage::getModel('index/process')->load(2)->reindexEverything(); /* 1 = Product Attributes 2 = Product Attributes 3 = Catalog URL Rewrites 4 = Product Flat Data 5 = Category Flat Data 6 = Category Products 7 = Catalog Search Index 8 = Tag Aggregation Data 9 = Stock Status */ ?> ## Delete cache/sessions ## bash rm -rf var/log/* rm -rf var/cache/* rm -rf var/session/* rm -rf var/report/* rm -rf var/locks/* rm -rf app/code/core/Zend/Cache rm -rf var/ait_rewrite/* rm -rf media/css/* rm -rf media/js/* // if there are many files which can't get deleted in once find /path/to/session/* -mt...

Change Price in cart Programatically in magento.

Hi,   Here for change the product price into cart programatically   There is an simple way for change this product price and add custom price for the specific product into cart when add the product into cart in magento. 1) Create an Attribute for the products,    Suppose an Ex. is Change Price    Set its type yes/no for the product 2) Open File, code/core/mage/checkout/model/cart.php 3) Goto on this function,      public function save()     {       ........       ........      } 4) Copy and Paste below code,     public function save()     {         Mage::dispatchEvent('checkout_cart_save_before', array('cart'=>$this));         $this->getQuote()->getBillingAddress();         $this->...

To Show the New Products in CMS Page with the Filter

<update handle="cms_page_layered" /> <reference name="content">    <block type="catalog/product_new" name="product_new" template="catalog/product/list.phtml">       <action method="setCategoryId"><category_id>6</category_id></action>       <action method="setColumnCount"><column_count>6</column_count></action>       <action method="setProductsCount"><count>0</count></action>       <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">          <block type="page/html_pager" name="product_list_toolbar_pager" />          <action method="setDefaultGridPerPage"><limit>12</limit></action>    ...