$category = Mage::getModel('catalog/category')->load($idCategoryForMoving);
$category->move($idParentCategory, $idAfterCategory);
2014-07-22
Move category
Getting filterable attributes in category
Getting filterable attributes from layered navigation
$category = Mage::registry('current_category');
$products = $category->getProductCollection();
$appliedFilters = Mage::getSingleton('catalog/layer')->getFilterableAttributes();
foreach ($appliedFilters as $filter) {
if ($value = $this->getRequest()->getParam($filter->getAttributeCode())) {
$products->addFieldToFilter($filter->getAttributeCode(), $value);
}
}
Method getFilterableAttributes returns all available attributes for filtering. Then in foreach we check if an attribute has been selected by user, we add it to the filter.
2014-07-17
Increase the size of a VDI file
You can only increase size
VBoxManage modifyhd YourFile.vdi --resize 32240
2014-07-16
Include third party libraries
For including third party libraries from lib folder
require_once(Mage::getBaseDir('lib') . '/simple_html_dom.php');
2014-06-27
Determine page type in magento
For category page (in layout xml file):
And in your block class you can get value of page type:category
$this->setPageType()For other pages you can do the same - just replace catalog_category_view with your action.
2014-06-23
Add column in magento install/upgrade script
For adding a new column to table in magento installer you have to add to your install/upgrade script:
$installer = $this;
$installer->startSetup();
// ...
$installer->getConnection()->addColumn(
$this->getTable('sales/quote_payment'),
'billing_code', // column name
'VARCHAR(255) NOT NULL' // type definition
);
// ...
$installer->endSetup();
2014-06-09
Rewrite controllers in magento
For rewriting controller in magento you have to add to your module config.xml:
SliRx_Test - your module which contains the controller for rewrite.
The above config means that magento will search the controller in your module first and after that, if doesn't find it, in Mage_Checkout.
Then you have to create the file SliRx/Test/controllers/CartController.php:
where Mage_Checkout - module with a controller which you are going to rewrite.SliRx_Test
SliRx_Test - your module which contains the controller for rewrite.
The above config means that magento will search the controller in your module first and after that, if doesn't find it, in Mage_Checkout.
Then you have to create the file SliRx/Test/controllers/CartController.php:
require_once(Mage::getModuleDir('controllers', 'Mage_Checkout') . DS . 'CartController.php');
class SliRx_Test_CartController extends Mage_Checkout_CartController
{
public function indexAction()
{
echo "it's cart!";
}
}
But magento doesn't know about Mage_Checkout_CartController and you must include the file with this class by yourself. That's why before declaring SliRx_Test_CartController calls require_once;
Subscribe to:
Posts (Atom)