Tuesday, 15 November 2011

Delete an attribute associated with a configurable product?

Go to table catalog_product_super_attribute and search with the condition
product_id= < "id of your configurable product">.
This will list all the attributes associated with this particular configurable product. Find the record with the corresponding attribute_id and delete it.

Monday, 14 November 2011

Magento – Get URL Paths for Skin, Media, JS, Base & Store URL

Tips to get Magento URL paths of skin, Media, JS, Base and Store URL in CMS pages for Magento customization or programming. How we can retrieve URL path from static blocks in CMS, PHP and phtml pages


To Retrieve URL path in STATIC BLOCK
To get SKIN URL
{{skin url='images/sampleimage.jpg '}}
To get Media URL
{{media url='/sampleimage.jpg'}}
To get Store URL
{{store url='mypage.html'}}
To get Base URL
{{base url='yourstore/mypage.html'}}


To Retrieve URL path in PHTML
Note: In editing PHTML don't forget to enclode the following code with PHP tag Not secure Skin URL
getSkinUrl('images/sampleimage.jpg') ?>
Secure Skin URL
getSkinUrl('images/ sampleimage.gif', array('_secure'=>true)) ?>
Get Current URL
$current_url = Mage::helper('core/url')->getCurrentUrl();
Get Home URL
$home_url = Mage::helper('core/url')->getHomeUrl();
Get Magento Media URL
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
Get Magento Skin URL
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
Get Magento Store URL
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
Get Magento Js URL
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);

Thursday, 10 November 2011

How To Simultaneously Add Multiple Products To A Magento Shopping Cart

Magento's product list view lets customers add products to the shopping cart one at a time. I wanted customers to be able to add multiple products to the shopping cart simultaneously. I created an adhoc AJAX method to accomplish this feature request. Adding a product to a Magento shopping cart is accomplished through an HTTP GET request. It will look like or similar to this:
/path/to/app/checkout/cart/add?product=[id]&qty=[qty] 

That URL is output by the tem­plate helper:

$this->getAddToCartUrl($_product)

Since adding a product to the shopping cart is nothing more than a GET request, then all that needs to be done is queue up the URLs of the desired products, make each request in order, and then reload the page when done. First, in app/design/frontend/default/your-theme/template/catalog/product/list.html, I first added checkboxes to allow customers to select which products they want and also hidden fields for storing the URLs to add the product and text fields for the quantity.

<?php $_iterator = $_product->getId(); >?


<?php if(!$_product->isGrouped()): ?>

<?php endif; ?>

I added this code within the loop that generate the HTML for the product line items for the list. Next, I added the JavaScript that does the actual processing, also within the list section right after the script block that contains: decorateList('products-list', 'none-recursive').

At the bottom of the list I added a submit button.

Clicking the button calls the function addItemsToCart(). The function hides the button to prevent a double click and unhides the status message. Next, the function determines which checkboxes are checked. For each checked checkbox, the function finds the corresponding URL field and quantity field, concatenates the two values, and stores the new URL in an array. If the length of the array is greater than 0, then the function calls processNext(), otherwise it displays an error message and resets the submit button.

The function processNext() first updates the process­ing message. The function takes the array of URLs and an index, and then creates an AJAX GET request using the URL at the given index in the array. If the AJAX request completes, it calls processNext() with the same array but with an incremented index while the index is less than the array length. If the incremented index is greater than the array length, then that ends the processing and the function reloads the page.

 That's it.

Wednesday, 9 November 2011

Magento: set number of products in new products

You can set number of products to be displayed in new product in your new.phtml file. Find:
 <?php $i=0; foreach ($_products->getItems() as $_product): ?>
and add above, so the code looks like this:
    <?php $_products->setOrder('news_from_date')->setPageSize(6)
  ->setCurPage(1);?>
    >?php $i=0; foreach ($_products->getItems() as $_product): ?>
Set the number (6) as you like. Or you can display all new product by $size = $_products->getSize(); set the number ($size). On the other hand you can set this number in administration on home cms page. Under Custom desing set the code for new products to look like this:

    
    8
    
    bundle
    bundle/catalog_product_price
    
    
    
    
Just set the number in tags.

Magento Cron error: /bin/sh: -c: line 0: syntax error near unexpected token `newline'

I got below error in my mail when i set up cron for magento.

/bin/sh: -c: line 0: syntax error near unexpected token `newline'
/bin/sh: -c: line 0: `php /home/pooja/public_html/magento/journal/cron1.php >'

I found solution for that is i remove newline space from my cron1.php file.
and its work.

Monday, 31 October 2011

Magento: Add to cart button every where

Sometime you need to add “Add to cart” button outside the product details view. So, you can’t use
getAddToCartUrl($product)

Don’t worry, you can use this code instead for:
echo Mage::helper('checkout/cart')->getAddUrl($_item)

Monday, 24 October 2011

Product images not uploading

When trying to upload an image for the product the section with the image name gets a red border and an error message appears.
When trying to upload something for the downloadable products same error found.


Here is what I did to fix it:
The problem seems to be caused by the prototype v1.7.
It works great with prototype 1.6
Get the 1.6 version from here http://prototypejs.org/assets/2009/8/31/prototype.js
or get it from older magento version.


Create this file: js/prototype/prototype1.6.js and put the contents from the link above in it.
Now edit app/design/adminhtml/default/default/layout/main.xml and change this line

prototype/prototype.js
with
prototype/prototype1.6.js


I don’t think it’s a problem if you edit this core file.  


I hope this helps someone