RSS

Category Archives: Magento

This category is for all magento posts

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..

Advertisements
 
1 Comment

Posted by on Sep 26, 2013 in Magento, Mysql, 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..

 

 
2 Comments

Posted by on Mar 30, 2012 in Magento, PHP

 

Tags: , , , , , , , , ,

How to call core template file in magento

1) For calling a core template file in .phtml file

<?php echo $this->getLayout()->createBlock(‘core/template’)->setTemplate(‘templateFolder/yourtemplate.phtml’)->toHtml(); ?>

2) For calling a core template file in CMS page

{{block type=”core/template” template=”templateFolder/your_template.phtml”}}

 
Leave a comment

Posted by on Mar 27, 2012 in Magento, PHP

 

Tags: , , ,

How to get random product of a category in magento

1) To Show the list of all product of a category in random order just copy & paste the following code anywhere in your magento template files:

<?php
$catid = '12';
$category = new Mage_Catalog_Model_Category();
$category->load($catid); // this is your special offers category id!
$collection = $category->getProductCollection();
Mage::getModel('catalog/layer')->prepareProductCollection($collection);
$collection->getSelect()->order('rand()');
$collection->addStoreFilter();
$numProducts = 5;
$collection->setPage(1, $numProducts)->load();
foreach($collection as $product) {
$product = Mage::getModel('catalog/product')->load($product->getId()); /* Load Products by ID*/
echo $product->getName();
echo $product->getShortDescription();
endforeach;
?>
 
3 Comments

Posted by on Feb 27, 2012 in Magento

 

Tags: , , , ,

How to add “View All” button in Magento’s pagination

Hi, Here is the solution of How to add view all option in magento pagination…

First of all, we need to trace the “app/design/frontend/your_package/theme/template/page/html/pager.phtml” file in our working template directory. When you do, all that needs to be added is the following code somewhere to fit your needs:

1
2
3
4
<a href="<?php echo $this->getLimitUrl('all')?>" title="< ?php echo $this->__('View All Products') ?>">
< ?php echo $this->__('View All') ?>
</a>

Now we’ve added our link to pagination. And only thing important here is the following segment of code:

1
$this->getLimitUrl('all')

This small segment of code generates our link with “limit” parameter set to “all”. Now when we click on it, it will give us a full category listing. The problem with that is that our value of “limit” set to “all” becomes stored permanently (for as long the session lasts). So we need to write just a couple lines of code more to fix it. Now  in “app/core/code/Mage/Catalog/Block/Product/List/Toolbar.php”  file, find the _construct() method. By default last line of that method is:

1
$this->setTemplate('catalog/product/list/toolbar.phtml');

which sets our (edited) template to this model. Just after that line, add the following code:

1
2
3
//ADDED FOR "VIEW ALL" PAGINATION BUTTON
$defaultLimit = $this->getDefaultPerPageValue();
Mage::getSingleton('catalog/session')->setData("limit_page",$defaultLimit);

So, this is it. I hope it will be helpful for someone.

 
3 Comments

Posted by on Jan 9, 2012 in Magento

 

Tags: , , ,

How to add reviews section in view.phtml in magento

In the catalog.xml layout:
app/design/frontend/default/custom/layout/catalog.xml

I added the following block to show the review form in view.phtml :

<block type="review/product_view_list" name="product.info.product_additional_data" as="product_review_data" template="review/product/view/list.phtml">
<block type="review/form" name="product.review.form" as="review_form">
<block type="page/html_wrapper" name="product.review.form.fields.before" as="form_fields_before" translate="label">
<label>Review Form Fields Before</label>
<action method="setMayBeInvisible"><value>1</value></action>
</block>
</block>
</block>

From app/design/frontend/default/custom/layout/review.xml

 

 
Leave a comment

Posted by on Dec 29, 2011 in Magento

 

Tags: , ,

 
%d bloggers like this: