HOW TO CHECK IF CURRENT PAGE IS HOMEPAGE?

In Magento, in order for you to check the current page if you are in home page / index page of your site, the following code work perfectly.

<?php if(
Mage::getSingleton('cms/page')->getIdentifier() == 'home'  &&
Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms' 
) : ? >

//insert your code here 

<?php endif; ?>

GET SKIN URL, GET MEDIA URL, GET BASE URL, GET STORE URL IN MAGENTO

To Retrieve URL path in STATIC BLOCK

To get SKIN URL

{{skin url='images/sampleimage.jpg'}}

To get Media URL

{{media url='/sampleimage.jpg'}}

To get Store URL

{{store url='mypage.html'}}

To get Base URL

{{base url='yourstore/mypage.html'}}

Get Magento Media Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);


Get Magento Media Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);

Get Magento Skin Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);

Get Magento Store Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);

Get Magento Js Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);

TO Retrieve URL path in PHTML

Note: In editing PHTML don't forget to enclode the following code with PHP tag
Not secure Skin URL:
<?php echo $this->getSkinUrl('images/sampleimage.jpg') ?>
Secure Skin URL
<?php echo $this->getSkinUrl('images/ sampleimage.gif', array('_secure'=>true)) ?>
Get  Current URL
$current_url = Mage::helper('core/url')->getCurrentUrl();
Get Home URL
$home_url = Mage::helper('core/url')->getHomeUrl();

magento search result is not working in 1.7.

Go to Path app/code/core/mage/catalogsearch/block/result.php

step 1 ) Uncomment lines 149 and 150

$this->getListBlock()
->setCollection($this->_getProductCollection());

step 2 ) Modify the line 172

change this line
$this->_productCollection = $this->getListBlock()->getLoadedProductCollection();

to

$this->_productCollection = Mage::getSingleton(‘catalogsearch/layer’)->getProductCollection();

when you will fix your code, goto the admin  panel (System -> Index Management) and select all the

Indexes > Pick action is “Reindex data” > and the press “submit” button.

And also one thing in admin panel is catalog search setting

Goto the System -> Config -> Catalog -> “Catalog Search”

Here, you can change your search type like, fulltext or both as you need.

Now goto the frontside and check i hope its work.

 

Drupal 6 node save with taxonomy term with php

 

global $user;

$tid = id of taxonomy term;

$new_node = new stdClass();
$new_node->type = ‘tips_for_life’; //Content type of node
$new_node->uid = $user->uid; //you can specify some other userID here if you want
$new_node->name = $user->name;
$new_node->title = ‘Tips 4 Life’;
$new_node->body = ‘test’;
$new_node->taxonomy = array($tid);
$new_node->field_tip_text[‘0’][‘value’] = $value;
$new_node->status = 1; // published
$node = node_save($new_node);
$done = node_submit($node);

Adding custom fields to products in Ubercart

Create a custom module

In mymodule.install, use db_add_field() like so:

mymodule_enable() {
  $ret = array();
  db_add_field($ret, 'uc_orders', 'newfield', array(
    'type'=>'varchar',
    'length'=>50)
  );
}

Simple! So now I’ve added a field to the database. Calling uc_order_load() works fine: the new fields are part of the order object since it just reads from the orders table; however, calling uc_order_save() will not update the new field.

There’s one more thing I needed to do. uc_order_save() calls drupal_write_record(), which depends on the schema. So mymodule needs to add its new field to the schema, using hook_schema_alter():

So what you do is write the following in mymodule.module:

mymodule_schema_alter(&$schema) {
  $schema['uc_orders']['fields']['newfield'] = array(
    'type' => 'varchar',
    'length' => 50,
    'description' => 'custom field',
  );
}