Saturday, December 27, 2014

jQuery-Parallax Scroll using jQuery

Parallax Scroll  using jQuery


<div>
  <ul>
   <li><a  href="#scroll1">Scroll 1</a></li>
   <li><a  href="#scroll2">Scroll 2</a></li>
   <li><a  href="#scroll3">Scroll 3</a></li>
   <li><a  href="#scroll4">Scroll 5</a></li>
   <li><a  href="#scroll5">Scroll 5</a></li>
  </ul>
</div>

<section id="scroll1" >Scroll Content 1  </section>
<section id="scroll2" >Scroll Content 2   </section>
<section id="scroll3" > Scroll Content 3  </section>
<section id="scroll4" > Scroll Content 4  </section>
<section id="scroll5" >Scroll Content 5   </section>


<script>
jQuery(function() {
  jQuery('a[href*=#]:not([href=#])').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {

      var target = jQuery(this.hash);
      target = target.length ? target : jQuery('[name=' + this.hash.slice(1) +']');
      if (target.length) {
        jQuery('html,body').animate({
          scrollTop: target.offset().top - 140
        }, 1000);
        return false;
      }
    }
  });
});
</script>

Note: 1.Please be sure, jQuery libary has included for the page.
          2.  Put sufficient content section part.

Njoy the day :) :)

Thursday, December 25, 2014

jQuery- Toggle Up and Dowm

 Toggle Up and Dowm


<div id="faq-list">
 <div class="overflow">
    <div class="to-bottom-border">
    <h2 class="ques">Click 1</h2>
    <div style="display:none;" class="answer">
     <p>Expanded 1</p>
     </div>        
     </div> 

<div class="to-bottom-border">
    <h2 class="ques">Click 2</h2>
    <div style="display:none;" class="answer">
     <p>Expanded 1 </p>
     </div>        
     </div>      
</div>
 </div>


 <script>
jQuery(document).ready(function() {
    jQuery('#faq-list h2').click(function() {
       
        jQuery(this).next('.answer').slideToggle(500);
       jQuery(this).toggleClass('close');
       
    });
}); // end ready
</script>

Note: Please be sure, jQuery libary has included for the page.

Njoy the day :) :)

Monday, September 15, 2014

Magento- Update Product Attribute value in Magento

Update Product Attribute value in Magento
$action = Mage::getModel('catalog/resource_product_action');
$action->updateAttributes(array($prdctid), array('attribute_key' =>'attribute_value'), 0);

Magento - Display New Products in Magento with Pagination

Display New Products in Magento with Pagination

Follow the following steps:

1. Create all of the folders/file in the following path if they do not already exist.
   app/code/local/Mage/Catalog/Block/Product/New.php

2.Put the below code on New.php
    <?php

    class Mage_Catalog_Block_Product_New extends Mage_Catalog_Block_Product_List
    {
       function get_prod_count()
       {
          //unset any saved limits
          Mage::getSingleton('catalog/session')->unsLimitPage();
          return (isset($_REQUEST['limit'])) ? intval($_REQUEST['limit']) : 12;
       }// get_prod_count

       function get_cur_page()
       {
          return (isset($_REQUEST['p'])) ? intval($_REQUEST['p']) : 1;
       }// get_cur_page

       /**
        * Retrieve loaded category collection
        *
        * @return Mage_Eav_Model_Entity_Collection_Abstract
       **/
       protected function _getProductCollection()
       {
          $todayDate  = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);

          $collection = Mage::getResourceModel('catalog/product_collection');
          $collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());

          $collection = $this->_addProductAttributesAndPrices($collection)
             ->addStoreFilter()
             ->addAttributeToFilter('news_from_date', array('date' => true, 'to' => $todayDate))
             ->addAttributeToFilter('news_to_date', array('or'=> array(
                0 => array('date' => true, 'from' => $todayDate),
                1 => array('is' => new Zend_Db_Expr('null')))
             ), 'left')
             ->addAttributeToSort('news_from_date', 'desc')
             ->setPageSize($this->get_prod_count())
             ->setCurPage($this->get_cur_page());

          $this->setProductCollection($collection);

          return $collection;
       }// _getProductCollection
    }// Mage_Catalog_Block_Product_New
    ?>

3.Put bellow lines on  app/design/frontend/default/your_theme/layout/catalog.xml

<reference name="content">
   <block type="catalog/product_new" name="product_new" template="catalog/product/list.phtml">
      <action method="setCategoryId"><category_id>10</category_id></action>
      <action method="setColumnCount"><column_count>6</column_count></action>
      <action method="setProductsCount"><count>0</count></action>
      <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
         <block type="page/html_pager" name="product_list_toolbar_pager" />
         <action method="setDefaultGridPerPage"><limit>12</limit></action>
         <action method="addPagerLimit"><mode>grid</mode><limit>12</limit></action>
         <action method="addPagerLimit"><mode>grid</mode><limit>24</limit></action>
         <action method="addPagerLimit"><mode>grid</mode><limit>36</limit></action>
         <action method="addPagerLimit"><mode>grid</mode><limit>48</limit></action>
         <action method="addPagerLimit" translate="label"><mode>grid</mode><limit>all</limit><label>All</label></action>
      </block>
      <action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>6</count></action>
      <action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
   </block>
</reference>
   
4. Put bellow line on CMS page
{{block type="catalog/product_new" column_count="6" products_count="0" name="home.catalog.product.new" alias="product_homepage" template="catalog/product/list.phtml"}}

Njoy :)

Ajax- submit form using ajax (With file/ image)

submit form (With file/ image) using ajax



<form action="#" name="uploader1" method="post" enctype="multipart/form-data" id="MyUploadForm">
    <span class="img1">Image 1</span><input name="file_upload" id="imageInput" type="file" />
    <input type="submit" name="submit"/>
    <span id="success1"></span>
</form>

<script type="text/javascript">
jQuery("form[name='uploader1']").submit(function(e) {
        var formData = new FormData(jQuery(this)[0]);

        jQuery.ajax({
            url: "http://your-domain/processupload.php",
            type: "POST",
            data: formData,
            async: false,
            success: function (msg) {
               // alert(msg)
                jQuery( "#success1" ).html(msg);
            },
            cache: false,
            contentType: false,
            processData: false
        });

        e.preventDefault();
    });
</script>
Note: Please be sure, jQuery libary has included for the page.

Njoy the day :) :)

Magento - getBaseUrl retrieving different urls

Magento getBaseUrl retrieving different urls


There are multiple ways for examples:- 
 
1. http://yourdomain.com/
<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); ?>

2. http://yourdomain.com/index.php/
<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); ?>

3.http://yourdomain.com/js/
<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS); ?>

4.http://yourdomain.com/media/
<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); ?>

5.http://yourdomain.com/skin/
<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN); ?>

 

Thursday, August 28, 2014

Magento - Add to cart button on upsell product page in magento

Add to cart button in upsell product page


To add "add to cart" button on upsell product page-
Follow below steps : -

1. open the upsell.phtml page:-
i.e.
app/design/frontend/default/your theme/template/catalog/product/list/upsell.phtml

2. Put the code where button to show-
<form action="<?php echo $this->getAddToCartUrl($_link) ?>" method="post" id="product_addtocart_form_<?php echo $_link->getId()?>"<?php if($_link->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
          <?php if(!$_link->isGrouped()): ?>
          <input type="text" name="qty" id="qty" maxlength="12" value="<?php echo ($this->getMinimalQty($_link)?$this->getMinimalQty($_link):20) ?>" />
          <label for="qty"><?php echo $this->__('Qty') ?>:</label>
          <?php endif; ?>
          <button type="button" onclick="this.form.submit()"><span><span><span><?php echo $this->__('Add to Cart') ?></span></span></span></button>
        </form>

Njoy :) :)