Posts

Showing posts from 2014

Magento MVC architecture & Module Development

>>>>>>>>>>>>>>>>>PHP MVC architecture<<<<<<<<<<<<<<<<<<<<<<<< In the typical MVC pattern, the flow of the application is something like this:     1) There is main entry point - index.php - from where the entire app routing mechanism is determined.     2) Based on this routing mechanism and requested URL pattern, the app will call the appropriate controller.     3) The controller then calls the appropriate views.     4) Finally, the view files collect the data from model files and display the data. >>>>>>>>>>>>>>>>>>Magento MVC architecture<<<<<<<<<<<<<<<<<<<<<< Magento's MVC architecture adds a few layers to the MVC pattern, but the basic flow of control of an application is l...

JQuery Basics

############--------jQuery Useful Scripts---################# ### To find the HTML content ## myhtml1 = jQuery("#narrow-by-list").find("dd.odd ol li a").first().html(); ## To make a condition ## if(myhtml1 == "Quilting Frames_duplicate") { jQuery("#narrow-by-list").find("dd.odd ol li a").first().attr('href','http://xyz.com'); } ## To get the href## jQuery('.wrapper').find('.col .logo11 a').attr('href') ### To get the image src,title### jQuery('.wrapper').find('.col .logo11 img').attr('src') jQuery('.wrapper').find('.col .logo11 img').attr('title') ### To change the href### jQuery("#narrow-by-list").find("dd.odd ol li a").first().attr('href','http://xyz.com'); #### To add a new Class ### jQuery('.wrapper').find('.col .logo11 a').addClass('hello'); ### To Find the...

To Get the Attribute Value Using a Entity id and With Resource Model

$entity_id=$_product->getEntityId();        $external_url= Mage::getResourceModel('catalog/product')->getAttributeRawValue($entity_id, 'external_url');

Error when uploading remote images using Magmi ( No URL set!)

If you are trying to import images from a remote server using "image","small_image","thumbnail" "http://example.com/img1","http://example.com/img2","http://example.com/img3" and Image attributes processor with debug mode enabled reported: Image attributes processor vX - error copying media/catalog/product/x/y/x.jpg; No URL set! if the image URL displays the right image then it is probably because the php function copy is not enabled on your server, to fix this open magmi/plugins/extra/itemprocessors/imageprocessor/imageitattributeemprocessor.php and modify the function     public function saveImage($imgfile, $target)     {         $result = $this->_mdh->copy($imgfile, $target);         return $result;     } by     public function saveImage($imgfile, $target)     {          ...

To Import in Magmi For the Multiple Root Categories or Multiple Stores

[RootCategoryName]/rahul/testing [Tv Cabinets]/rahul/testing

Always Show Shipping Costs in Magento

http://www.rapidcommerce.eu/blog/2012/04/allways-show-shipping-costs-in-magento/ Instructions for installing this extension: 1. Download the zip (DUH!) 2. Extract it’s contents to the root of your Magento installation. You can use FTP to do that. It’s the directory containing index.php [App] [Skin] [Media] among others 3. Log in to your Magento backend 4. Go to System -> Cache Management, select all options, and in the action dropdown select “Refresh”. Then click Submit. 5. Log out/in to your backend 6. Go to System -> Configuration -> Shipping Settings and drop down the “Origin” selection 7. This extension adds two new options here; “Apply defaults to empty quote” and “Default shipping method” 8. Set “Apply defaults to empty quote” to “Yes” , set “Default shipping method” to your preferred shipping method. And make sure “Country” is set. 9. Click save config. 10. All done!

To Get the Category id

$categoryid = Mage::getModel('catalog/layer')->getCurrentCategory()->getId(); $catagory_model = Mage::getModel('catalog/category')->load($categoryid); echo $catagory_model->getDescription();

Scroll Top

<p id="back-top"><a href="#top"><span>Back to Top</span></a></p> <!-----scroll top---include the js file if its needed> <script> jQuery(document).ready(function(){     // hide #back-top first     jQuery("#back-top").hide();     // fade in #back-top     jQuery(function () {         jQuery(window).scroll(function () {             if (jQuery(this).scrollTop() > 300) {                 jQuery('#back-top').fadeIn();             } else {                 jQuery('#back-top').fadeOut();             }     ...

Ajax Post in Cross Sell

crosssell.php ----------------------------------------------------------------------------------------------------------------------------------  <?php $buttonTitle1 = $this->__('Add to Cart'); ?>  <?php $_helper = $this->helper('catalog/output'); ?> <?php $_product = $this->getProduct(); ?> <?php $_wishlistSubmitUrl = $this->helper('wishlist')->getAddUrl($_product); ?> <?php $_crossSellProducts = $_product->getCrossSellProducts(); if(count($_crossSellProducts) > 0) {       echo '<style>       #product_tabs_upsell_products_tabbed{         display:block;     }         </style>'; } else {     echo '<style>       #product_tabs_upsell_products_tabbed{         display:none;  ...

Detail Page Externally

<?php require_once('app/Mage.php'); //Path to Magento umask(0); Mage::app(); $val=$_POST['name']; $val1=$_POST['name_b']; $comp=$_POST['name_c']; $wish=$_POST['name_d']; ?> <?php $productID=$val; $_product = Mage::getModel('catalog/product')->load($productID); //echo '<pre>'; //print_r($_product); ?> <?php //$_url = Mage::helper('checkout/cart')->getAddUrl($_product); //echo $_url ; ?> <?php ?> <div class="border"></div> <div style="overflow:hidden;">     <div class="pop-up-image">         <?php                     if($_product->getSmallImage()=='no_selection') { ?>     <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); ?>catalog/productno_selection/noimage.jpg" width=100 height=100 /> <?php      ...

To Check the Disble/Enable Category in Magento Based on the Category ID

$_category = Mage::getModel('catalog/category')->load(4871);   echo $_category->getIsActive();

Run Magento Code Externally

<?php require_once ( 'app/Mage.php' ); //Path to Magento umask(0); Mage::app(); // Now you can run ANY Magento code you want // Change 12 to the ID of the product you want to load $_product = Mage::getModel( 'catalog/product' )->load(12); echo $_product ->getName();

To Get the Value From Ajax

--------------------------------------------------------------         <div class="divButtons">                 <a data-toggle="modal" href="#windowTitleDialog" class="product_id"><span><img src="<?php echo $this->getSkinUrl('images/cart_button2.png'); ?>" alt="" title="" /></span></a>                 <?php                     $_compareUrl = Mage::helper('catalog/product_compare')->getAddUrl($_item);                     $_wishlistUrl =Mage::helper("wishlist")->getAddUrl($_item);                 ?>              ...

To Get the Hidden Input Field Value Using Jquery

 <div class="divButtons">                 <a data-toggle="modal" href="#windowTitleDialog" class="product_id">Set Window Title</a>                                 <input type="hidden" id="h_v" class="hv" name="rahul" value="<?php echo $_item->getId(); ?>">                                 </div> <script> jQuery(document).ready(function()     {         jQuery(".product_id").click(function()         {             var key=jQuery(this).parent().find(".hv").val();           ...

Script to Make a Duplicate Category

<?php require_once('app/Mage.php'); umask(0); Mage::app('admin'); error_reporting(1); set_time_limit(0); ini_set('memory_limit', '2048M'); // COPY Products From => To // 5 => 10 if(isset($_REQUEST['from'])){     $from = $_REQUEST['from'];     $to = $_REQUEST['to'];     $category = Mage::getModel('catalog/category')->load($from);         $productCollection = $category->setStoreId(1)->getProductCollection();         foreach($productCollection as $_product) {      $product = Mage::getModel('catalog/product')->load($_product->getId());          $newCategories = $origCats = $product->getCategoryIds();      if(!in_array($to, $origCats)) {      $newCategories = array_merge($origCats, array($to));      $product->setCategor...

Get Attribute Value on Product Page Based on the Attribute Code

echo $_product->getAttributeText('your_attribute_code');

How to Get Attribute Name and Value?

Attribute in Magento is like a property. All Products, Categories, Orders, Customers, etc. have attributes. For example, the attribute of a product is its name, sku, description, image, etc. This article will show you how to get attribute name and value for any product. Get attribute’s name, value, type, and other parameters The attribute code in the case below is my_attribute . /**   * get attribute collection   */ $attribute = $_product ->getResource()->getAttribute( 'my_attribute' ); /**   * get attribute type   */ $attribute ->getAttributeType(); /**   * get attribute Label   */ $attribute ->getFrontendLabel(); /**   * get attribute default value   */ $attribute ->getDefaultValue(); /**   * check if the attribute is visible   */ $attribute ->getIsVisible(); /**   * check if the attribute is req...