Magento: Add dynamic blocks in phtml files

Magento: Add dynamic blocks in phtml files

Magento: Add dynamic blocks in phtml files

To add dynamic blocks in phtml files. you can add this code to any where as you want in the phtml files like view.phtml:

<?php echo $this->getLayout()->createBlock('moduleName/blockType')->setTemplate('moduleName/templateName.phtml')->toHtml(); ?>
/*
- moduleName: your module's name (Ex: catalog)
- blockType: the path to block file (Ex: product_view ) (Catalog/Block/Product/View.php)
*/ 

Magento: How to get any category’s description in Magento

How to get any category’s description in Magento

How to get any category’s description in Magento

First, let’s talk about how to get category by category id in Magento.

It’s easy to get category by id, just change the number in load() method.

$category=Mage::getModel('catalog/category')->load(23);

Then this is the dsecription:

echo $category->getDescription();

You can change the description in Catelog->Category in the backend, and you can easily get other attributes just change the getDescription() method.

PHP: Adding Parameters To A URL in PHP

PHP: Adding Parameters To A URL in PHP

Adding Parameters To A URL in PHP

This article shows how to add query parameters to a URL in a php script. It is aimed at the beginner to intermediate level PHP programmer but developers from other languages may find some useful information here. At first this seems like a simple enough task. Starting with the url as a string, just add the new parameters to the end. Yeah, that would be nice. It turns out that there are a few conditions that make the process just a bit more difficult. It’s still not a hard problem but there are enough special cases to make it interesting.
(more…)

CSS: Style links depending on file format

CSS: Style links depending on file format

CSS: Style links depending on file format

A short CSS snippet that changes the styling of external links, email links and links to pdf documents.

/* external links */
a[href^="http://"]{
    padding-right: 20px;
    background: url(external.gif) no-repeat center right;
}

/* emails */

a[href^="mailto:"]{
padding-right: 20px;

background: url(email.png) no-repeat center right;

}

/* pdfs */

a[href$=".pdf"]{
padding-right: 20px;
background: url(pdf.png) no-repeat center right;

Magento: Problem with reindexing process for “Product flat data” indexes

Problem with reindexing process for "Product flat data" indexes

Problem with reindexing process for "Product flat data" indexes

Symptoms

Reindexing of Product flat data index gives unknown reindexing error or “Some problem with reindexing process” error message or reindexing of Product flat data index is never completed.

Attempt to reindex it via command line gives the following error message:

$ php -f shell/indexer.php -- --reindex catalog_product_flat
Product Flat Data index process unknown error:
exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (<result 2 when explaining filename '#sql-'>, CONSTRAINT ´FK_CAT_PRD_FLAT_1_ENTT_ID_CAT_PRD_ENTT_ENTT_ID´ FOREIGN KEY (´entity_id´) REFERENCES ´catalog_product_entity´ (´entity_id)' in lib/Zend/Db/Statement/Pdo.php:228

(more…)

Magento: How to get current currency in Magento?

How to get current currency in Magento?

How to get current currency in Magento?

We know Magento support multiple currency. I have found the solution to check current currency in the Magento site frontend

To get Current Currency

<?php echo $currency_code = Mage::app()->getStore()->getCurrentCurrencyCode(); ?>

If you looking for current currency symbol use :

<?php
echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
?>

Magento: Automated Bash Script Installer

Magento: Automated Bash Script Installer

Magento: Automated Bash Script Installer

The following SSH script will automate the process of installing Magento, with or without sample data. It will walk you through everything, and the only thing you need to setup first is the database and assign a user to the database.

You will need SSH access to use this. SSH is similar to FTP, in that it requires software that you’ll need to download in order to connect to your site. If you don’t have an SSH client, you can download PuTTY for free.
(more…)

CSS: Drop Caps

CSS: Drop Caps

CSS: Drop Caps

Use the first-letter Pseudo-Class

The easiest way to create CSS Drop Caps is to use the first-letter pseudo-element on the element you want to have a drop cap. The problem is, this isn’t supported in all browsers. Be sure to test this in the browsers your Web site supports.

Type the following and place it in a

element at the top of your Web page:
(more…)

Page 9 of 24«6789101112»

Pin It on Pinterest