RSS

For adding a custom browse field for uploading image of type ICO, PNG, GIF, JPG, JPEG, APNG, SVG add the following snippet of code…

<shortcut1_icon translate="label comment">
<label>Favicon Icon</label>
<comment>Allowed file types: ICO, PNG, GIF, JPG, JPEG, APNG, SVG. Not all browsers support all these formats!</comment>
<frontend_type>image</frontend_type>
<backend_model>adminhtml/system_config_backend_image_favicon</backend_model>
<base_url type="media" scope_info="1">favicon</base_url>
<sort_order>5</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</shortcut1_icon>

at the following location..

app/code/core/mage/page/etc/system.xml

You can get the following file name in frontend as follws

Mage::getStoreConfig('design/head/shortcut1_icon');

by this way you can see a browse field in admin area at following location…

admin > system > configuration > General > design > HTML Head
 
Leave a comment

Posted by on Oct 3, 2013 in PHP

 

Tags: , , , , , ,

How to search for all words in magento?

If u want to make an AND search instead of OR, you will need to rewrite the class

Mage_CatalogSearch_Model_Resource_Fulltext

at this location in magento v1.7.0.2.

app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php

Now Go to the following function in this file

public function prepareResult($object, $queryText, $query)

You have to change the following line

$likeCond = '(' . join(' OR ', $like) . ')';

To

$likeCond = '(' . join(' AND ', $like) . ')';

Now change the Search Type to “LIKE” from catalog search section in admin.

Now reindex the search index afterwards to have an effect..

 
Leave a comment

Posted by on Sep 26, 2013 in Magento, Mysql, PHP

 

Tags: , , , , , , , , , , ,

Link

Natural Language Full-Text Searches

MySQL has support for full-text indexing and searching:

  • A full-text index in MySQL is an index of type FULLTEXT.

  • Full-text indexes can be used only with MyISAM tables, and can be created only for CHARVARCHAR, or TEXTcolumns.

  • FULLTEXT index definition can be given in the CREATE TABLE statement when a table is created, or added later using ALTER TABLE or CREATE INDEX.

  • For large data sets, it is much faster to load your data into a table that has no FULLTEXT index and then create the index after that, than to load data into a table that has an existing FULLTEXT index.

 
Leave a comment

Posted by on Feb 22, 2013 in PHP

 

Ajax pagination with jQuery in cakephp 2.x.x

For apply ajax pagination in cakephp 2.x.x follow these below steps:

Image

1). Copy File JqueryEngineHelper.php From lib/Cake/View/Helper and Paste to  app/View/Helper.

2). Include Latest jQuery File to your layout file for ajax paging.

ex- in app/View/Layouts/ajaxpagination.ctp

<!DOCTYPE html>
<html>
<head>

<!– This is mandotary –>
<?php echo $this->Html->script(‘http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&#8217;); ?>
</head>
<body>
<div id=”spinner” style=”display: none; float: right;”>
<?php echo $this->Html->image(‘indicator.gif’, array(‘id’ => ‘busy-indicator’)); ?>
</div>
<div id=”content”>
<?php echo $content_for_layout; ?>
</div>

</body>
</html>

NOTE: Here ‘indicator.gif’ image is a loader image.you can place this image in app/webroot/img directory.

3).  To make Javascript enhanced links instead of plain HTML links, you have to use options() parameter to paginator helper .

ex- In your view ctp file add the following:

<!– This is mandotary –>
<?php $this->paginator->options(array(‘update’ => ‘#content’,’before’ => $this->Js->get(‘#spinner’)->effect(‘fadeIn’, array(‘buffer’ => false)),’complete’ => $this->Js->get(‘#spinner’)->effect(‘fadeOut’, array(‘buffer’ => false))));?>

Showing Page <?php echo $this->paginator->counter(); ?>
<table>
<tr>
<th><?php echo $this->paginator->sort(‘Post.title’, ‘Title’);?></th>
<th><?php echo $this->paginator->sort(‘Post.created’, ‘Created Date’);?></th>
</tr>
<?php foreach($customers as $customer): ?>
<tr>
<td style=”padding-right: 30px;”><?php echo $customer['Post']['title']; ?></td>
<td style=”padding-left: 30px;”><?php echo $customer['Post']['created']; ?></td>
</tr>
<?php endforeach; ?>
</table>

<?php echo $this->paginator->prev(); ?> – &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<?php echo $this->paginator->numbers(array(‘separator’=>’ – ‘)); ?> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<?php echo $this->paginator->next(‘Next Page’); ?>
<?php echo $this->Js->writeBuffer();?> <!– This is mandotary –>

At the bottom of your view file. Be sure to include:

<?php echo $this->Js->writeBuffer();?>

If you omit this you will not be able to chain ajax pagination links. When you write the buffer, it is also cleared, so you don’t have worry about the same Javascript being output twice.

4). Controller File. add the following lines to your controller action:

$this->layout = ‘ajaxpagination’;
$this->set(‘customers’, $this->paginate(‘Post’)); <!– Record from the model which you want to show in view file with pagination. –>

 
3 Comments

Posted by on Feb 7, 2013 in Cake PHP, PHP

 

Tags: , , , , , , , ,

CONCAT in query , Virtual Fields and make a drop down

I need to make a dropdown list of Locations. In dorpdown i need to put location name and location state name. I already have a column in database name which contain location name and location state name. Here is the steps to do so:

In Location Model(in which database table locations are saved) write the following code

1 var $virtualFields = array('dropdown_name' => 'CONCAT(Location.location_name, " ", Location.location_state)');
In Controller in which you want to show dropdown write this(eg: ShowsController):
2 $this->loadModel('Location');
$loc_list = $this->Location->find("list", array("fields" => array("location_id", 'location_name')));
$this->set('loc_list',$loc_list);
In view template(eg. View/Shows/add.php) add the following
2 $this->loadModel('Location');
$loc_list = $this->Location->find("list", array("fields" => array("location_id", 'location_name')));
$this->set('loc_list',$loc_list);
 
Leave a comment

Posted by on May 14, 2012 in Cake PHP, PHP

 

Tags: , , , ,

Add custom attribute to Magento invoice PDF

Look in the file app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php. That contains the part necessary for product output. Copy the file to a matching directory path but in app/code/local, this is a safe way to override and make edits. You should be able to see how the $lines array is used for positioning text.

Try inserting something like this either just before or just after the custom options.

// The quote item doesn't have any product attributes, it is only a quote! $product = Mage::getModel('catalog/product')->load($item->getProductId()); // Use the actual product object to add a new line. $lines[][] = array(     'text' => Mage::helper('core')->__('Manufacturer SKU: ') . $product->getManufacturerSku(),     'feed' => 35 );
You can try to change the position of attribute value by changing the value of feed. For more detail follow this link:-
http://inchoo.net/ecommerce/magento/how-to-add-custom-attribute-to-magentos-pdf-invoice/
 
Leave a comment

Posted by on May 7, 2012 in Magento, PHP

 

Tags: , , ,

How do I get a list of active filters?

<?php /*Create filter dependencies*/

$_activeFilters[] = array();

$_filters = Mage::getSingleton(‘Mage_Catalog_Block_Layer_State’)->getActiveFilters();

foreach ($_filters as $_filter):?>
<?php echo $this->stripTags($_filter->getLabel()) ?><a href=”<?php echo $_filter->getRemoveUrl() ?>” title=”<?php echo $this->__(‘Remove This Item’) ?>”><?php echo $this->__(‘Remove This Item’) ?></a>
<?php endforeach; ?>

 

in this way you can get list of all active filters and placed them any catalog template files..

 

 
Leave a comment

Posted by on Mar 30, 2012 in Magento, PHP

 

Tags: , , , , , , , , ,

 
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: