Friday, June 2, 2017

Display specific products on homepage magento

Hello

Now i explain you how to display any specific products on homepage of magento. In admin side, you have to give product ids with coma, and it will display that products.

1st step : Create custom-list1.phtml file in this path : app/design/frontend/[yourthemename]/default/template/catalog/product/

Code:
Start code
<?php
$data=$this->getData('product_id');
    $productIds = explode(',',$data);

    $products = Mage::getModel('catalog/product')->getCollection()
            ->addAttributeToSelect('*')
                ->addAttributeToFilter('entity_id', array('in' => $productIds));
       
    $products->getSelect()->order("find_in_set(entity_id,'".implode(',',$productIds)."')");

    $_helper = $this->helper('catalog/output');
    ?>
  
    <div class="category-products">
   
        <ul class="products-grid row">
<?php foreach($products as $_product){  ?>
            <li class="item col-xs-12 col-sm-3" style="margin-left:0 !important;" >
                <div class="wrapper-hover">
                    <a href="<?php echo $_product->getUrlInStore(array('_ignore_category' => true)); ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" class="product-image"><img  src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->keepFrame(true)->resize(255,344)->keepAspectRatio(true); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" /></a>
                    <div class="product-shop">
                        <?php $productBlock = $this->getLayout()->createBlock('catalog/product_price');
                            echo $productBlock->getPriceHtml($_product); ?>
                            <?php $ab = $_product->getTierPrice(); if($ab){ ?>
                            <?php $_groupedProductChildPrices=array();

// get child products of grouped product
//
$_childProductIds = $_product->getTypeInstance()->getChildrenIds($_product->getId());

foreach ($_childProductIds as $_ids) {

    foreach ($_ids as $_id) {

        $_childProduct = Mage::getModel('catalog/product')->load($_id);

        // get all associated group product pricing, including tier prices
        $_groupedProductChildPrices[] = $_childProduct['price'];

            if($_childProduct->getTierPrice() != NULL) {
                foreach($_childProduct->getTierPrice() as $tier){
                    $_groupedProductChildPrices[]= $tier['price'];
                }
            }

    }
}?>
<div class="price-box">
<a href="<?php echo $_product->getProductUrl(); ?>" class="minimal-price-link">
<span class="label"><?php echo $this->__('As low as:') ?></span>
        <span class="price" id="product-minimal-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
               <?php echo '$'.$_lowestGroupProductPrice=round(min($_groupedProductChildPrices),2); ?>
            </span>
                            </a></div><?php } //endif $ab ?>
                        <h3 class="product-name">
                            <a href="<?php echo $_product->getUrlInStore(array('_ignore_category' => true)); ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>">
                                <?php $small_getName = strip_tags($this->htmlEscape($_product->getName()));
                                 if (strlen($small_getName) < 20) echo($small_getName);
                                 else { echo mb_substr($small_getName, 0, 50,'UTF-8').'...';} ?>
                            </a>
                        </h3> 
                       <div class="wrapper-hover-hiden">
                           <div class="desc_grid"><?php $small_getDescription = strip_tags($_product->getShortDescription());
                                 if (strlen($small_getDescription) < 101) echo($small_getDescription);
                                 else { echo mb_substr($small_getDescription, 0, 85,'UTF-8').'...';} ?></div>
                            <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
                            <div class="actions">
                                <?php if($_product->isSaleable()): ?>
                                    <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $_product->getUrlInStore(array('_ignore_category' => true)); ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
                                <?php else: ?>
                                    <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                                <?php endif; ?>
                               
                            </div>
                       </div>
                       <div class="viewproduct">
                           <button type="button" title="<?php echo $this->__('View This Product') ?>" class="button btn-cart" onclick="setLocation('<?php echo $_product->getUrlInStore(array('_ignore_category' => true)); ?>')"><span><span><?php echo $this->__('Shop Now') ?></span></span></button>
                       </div>
                    </div>
                    <?php $_product = Mage::getModel('catalog/product')->load($_product->getId()); ?>
                    <div class="label-product">       
                        <?php if (date("Y-m-d") >= substr($_product->getNewsFromDate(), 0, 10) && date("Y-m-d") <= substr($_product->getNewsToDate(), 0, 10)) {echo '<span class="new">'.$this->__('New').'</span>'; } ?>
                        <?php if($_product->getData('new')){echo '<span class="new">'.$this->__('New').'</span>';  }?>
                        <?php if($_product->getData('sale')){echo '<span class="sale">'.$this->__('Sale').'</span>';  }?>
                    </div>
                    <div class="clear"></div>
                </div>
            </li>
        <?php } ?>
        </ul>
</div>
End code

2nd step : Go to your homepage cms page and put this code :

<div class="row">
<div class="page-title col-xs-12 category-title1">
<h2>Picked by admin:</h2>
</div>
</div>
<div class="home_block">{{block type="catalog/product_list" column_count="3" product_id="519,513,511,506" template="catalog/product/custom-list1.phtml"}}</div>

3rd Step :  Now do these :
  1. Navigate to System->Permissions->Blocks.
  2. Click on the Add new block button.
  3. Specify your Block Name, which is: catalog/product_list.
  4. And allow the Block using the YES/No Dropdown list:
4th Step : Clean your all catch

Now you can hard refresh your home page.

Reference : https://www.templatemonster.com/help/magento-how-to-display-products-of-specific-category-on-home-page.html

Thursday, May 18, 2017

Create email id without registration

Hello all.
I face many problem while testing email id. Every time i have to create new email id and use that id. It takes more time. i think it is completely waste of time. So i found new way. I used http://www.yopmail.com for testing email.


It is very simple. Open this url and simply enter your name. And this email id is open. No need to signup or password. Its so much easy. You can create email id without registration.



Monday, May 15, 2017

Magento Email id and name change from hard code

If you want to change default sender name and email id from magento, follow these steps :-


1 : Login in FTP and go to this path : app/code/core/Mage/Core/etc/


2 : Open file 'config.xml'
changed these lines :
 <trans_email>
            <ident_custom1>
                <email>custom1@example.com</email>
                <name>Custom 1</name>
            </ident_custom1>
            <ident_custom2>
                <email>custom2@example.com</email>
                <name>Custom 2</name>
            </ident_custom2>
            <ident_general>
                <email>owner@example.com</email>
                <name>Owner</name>
            </ident_general>
            <ident_sales>
                <email>sales@example.com</email>
                <name>Sales</name>
            </ident_sales>
            <ident_support>
                <email>support@example.com</email>
                <name>CustomerSupport</name>
            </ident_support>
        </trans_email>

Do this if you dont want to change any name.

Magento email not sends or transcation emails are not working

Hello

Recently i face one problem that emails are not send by magento. User registration, password reset, sales email are not working. Server is working fine. I  checked lots off code. Nothing found as malicious. In last found that one custom email template is created that causes problems. Even i not used that template. I make it only for testing and i never applied for any email. So be careful while create any template. Even if you are not using, it affect your magento.  Good practice is avoid this type of test codes.


Friday, May 5, 2017

magento admin display 404 error

Hello

I transferred a website to another server. Copied all files and imported database. Frontside is working fine but admin side is not opening. It display 404 error. I re-upload database, cleared catch and sessions. But nothing happen. After i google it. Tried to many solutions. And last one query solved my problem.
Here is the solution.
Go to your phpmyadmin and run this query.

SET FOREIGN_KEY_CHECKS=0;
UPDATE `core_store` SET store_id = 0 WHERE code='admin';
UPDATE `core_store_group` SET group_id = 0 WHERE name='Default';
UPDATE `core_website` SET website_id = 0 WHERE code='admin';
UPDATE `customer_group` SET customer_group_id = 0 WHERE customer_group_code='NOT LOGGED IN';
SET FOREIGN_KEY_CHECKS=1;

I saw that this is happen in shared server.

Wednesday, May 3, 2017

Top 4 jQuery Image Cropping / Resizing Plugins

Uploading big photo take lot’s of space on server, you must have seen this feature on big website like facebook and google+ while uploading profile pic you can crop your photo and resize pic during upload, It helps to choose best size of your photo and also reduce space on server.

1. RCrop – Responsive Cropper Jquery Plugin

 Responsive Cropper is a JQuery plugin that lets you select an area from an image and prepare crop information to send it to the server.
You don’t need to trigger any event to update crop area when image is resized: this plugin is full responsive. Crop area uses percentages to guarantee full responsiveness, while crop data is stored separately in absolute values.
You can access to crop data easily throw methods, but also plugin makes things easy for you: inputs are are generated and filled with crop information to send to the server.
Last, you can activate a preview or, even, get a base64 image encoded. All that on the client side.
Features:
* Responsive (percentage values)
* Preserve Aspect ratio: shift key or from options
* Easy CSS/SCSS full customization
* Grid
* Minimum and Maximum crop area
* Mobile compatibility
* Methods and Events

DOWNLOAD


2. Simple Cropper

Simple Cropper is a jQuery plugin which gives you ability to add cropping functionality to your web application. It uses html5 canvas to create cropped images and css3, so it only works on latest browsers.
Features:
* Attaches to any div element
* Automatically detects aspect ratio of an element
* Creates new cropped(base64 encoded) image and inserts it into element
* Cropped images are generated client-side
* Support for CSS styling

DOWNLOAD

 

3. Jquery Cropbox

 jQuery plugin for in-place image cropping (zoom & pan, as opposed to select and drag).
This plugin depends only on jQuery. If either Hammer.js or jquery.hammer.js is loaded, the cropbox plugin will support gestures for panning and zooming the cropbox. Similary, if the jquery.mousewheel.js plugin is loaded, then the cropbox plugin will support zoom in & out using the mousewheel. All dependencies on third party libraries (other than jQuery) are strictly optional. Support for CommonJS and AMD loading is built in.
In browsers that support the HTML5 FIle API and Canvas API, the cropbox plugin provides mehtods to crop the image on the client and obtain the resulting cropped image as a Data URL or a binary blob to upload it to the server.

DOWNLOAD

4. Croppie – A Javascript Image Cropper

Croppie is a fast, easy to use image cropping plugin with tons of configuration options, Croppie is an Html5 canvas based image cropping library that lets you create a square or circular viewport permitting to visually resize an image while preserving aspect ratio and perform a crop. Also can be used as a jQuery plugin.

DOWNLOAD

Tuesday, May 2, 2017

Simple random banner rotator in Magento using static blocks

This is not slider. This is simple image rotator. Every refresh make image changed in page.

In admin panel add N static blocks (“CMS->Static Blocks->Add new block”)
For identifier field use something like this:

SomeBannerIdentifierName_1
SomeBannerIdentifierName_2
SomeBannerIdentifierName_3
...
SomeBannerIdentifierName_N

For each content use this:
<a href="ADDRESS_YOU_WANT_TO_USE"><img src="{{skin url=images/media/IMAGE_YOU_WANT_TO_USE.jpg}}" alt="Some alt text"  /></a>
 
Please note that you are not restricted only to images, you could use text, video or whatever you want here, but I’ll focus on images with links as title says. (you have to create folder  "callouts")
Now when all is set, make new file called banner_rotator.phtml in  “/app/design/frontend/YOUR_INTERFACE/YOUR_THEME/template/callouts/banner_rotator.phtml

 And use this code inside:
<?php
 echo $this->getLayout()->createBlock('cms/block')->setBlockId('SomeBannerIdentifierName_'.mt_rand(1, N))->toHtml()  
?>
 
*Make sure you replace “N” with highest number of your static block
In order to show this block, you should be familiar with Magento layouts.
Since that is out of scope for this article, I’ll show you how to put it below the content on cms pages.
Open “/app/design/frontend/YOUR_INTERFACE/YOUR_THEME/layout/cms.xml
[*] Put this line:

<block type="core/template" name="home.banner.rotator" template="callouts/banner_rotator.phtml"/>
 
 
 Find this:

<cms_page>
<reference name="content">
<block type="cms/page" name="cms_page"/>
 
P U T  [*] H E R E  ! ! !
 
</reference>
</cms_page>
 
Unfortunately I can’t be more specific so feel free to ask me anything.
UPDATE:
If you want this to work for specific page such as homepage do this:
Instead of here /app/design/frontend/YOUR_INTERFACE/YOUR_THEME/layout/cms.xml
put this:

<reference code="content">
<block type="core/template" name="home.banner.rotator" template="callouts/banner_rotator.phtml"/>
</reference>
 
 
or put this code

{{block type="core/template" name="home.banner.rotator" template="callouts/banner_rotator.phtml"}}
 
into your Admin panel’s CMS->Pages->Your page->Design->Layout Update XML field
Everything else is the same…