ALTER TABLE `coupon_aggregated` CHANGE COLUMN `period` `period` DATE NOT NULL DEFAULT ‘0000-00-00’
Thursday, 5 April 2012
Magento 1.6.2.0 Syntax error or access violation: 1067 Invalid default value for ‘period‘
Wednesday, 29 February 2012
magento "No shipping information available" in orders
I have problem of shipping description not display in order and order email. After search for that and nothing found and finally i have do that. Its because i have code changed in file app\code\core\Mage\Sales\Model\Quote\Address\Total\Shipping.php in line no 168. i have put something like that.
$shippingDescription = ""; // $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle();
Than I have remove this do as it default see below.
$shippingDescription = $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle();
I have do this stuff because i want remove shipping info display in cart page total box where i want only display "Shipping & Handling".
And goto above file around line no 189 and i comment out below code and its hide info of shipping in cart page total box.
//if ($address->getShippingDescription()) {
// $title .= ' (' . $address->getShippingDescription() . ')';
//}
Friday, 24 February 2012
How To Change Order Status in Magento1.6
I searched all around to find this solution. In Magento Commerce, there is no provision for manually changing order status from the admin panel. I have also try to change in Magento\app\code\core\Mage\Sales\etc\config.xml file but i cant change in magento1.6. so finally i got below solution i hope this work for you.
Open file app\design\adminhtml\default\default\template\sales\order\view\history.phtml in this file.
Also replace the code.
<?php foreach ($this->getStatuses() as $_code=>$_label): ?>
<?php endforeach; ?>
with
<?php
$selected = "";
foreach (Mage::getSingleton('sales/order_config')->getStatuses() as $_code=>$_label):
if($_code==$this->getOrder()->getStatus())
$selected = 'selected="selected"';
echo "";
endforeach;?>
Its works perfectly for me i hope its work for you.
Monday, 20 February 2012
Magento Fatal error: Call to a member function is Shipping Labels Available() on a non-object
When I click the Ship button, I get this error in the lower right corner, where there should be a button:
Fatal error: Call to a member function isShippingLabelsAvailable() on a non-object in /var/www/limp/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Items.php on line 132
Here i got solution for it just replace text shown in below.
change line 1214 of app/code/core/Mage/Sales/Model/Order.php from
$shippingMethod = parent::getShippingMethod();
to
$shippingMethod = $this->getData('shipping_method');
I hope this work for you.
Thursday, 16 February 2012
Sort a category and subcategory list array alphabetically in Magento
<?php
$cats = Mage::getModel('catalog/category')->load(2)->getChildren();
$catIds = explode(',', $cats);
$categories = array();
$subCategories = array();
foreach ($catIds as $catId) {
$category = Mage::getModel('catalog/category')->load($catId);
$categories[$category->getName()] = $category->getUrl();
$subcats = Mage::getModel('catalog/category')->load($catId)->getChildren();
$subcatIds = explode(',', $subcats);
if ($subcats) {
foreach ($subcatIds as $subcatId) {
$subCategory = Mage::getModel('catalog/category')->load($subcatId);
$subCategories[$category->getName()][$subCategory->getName()] = $subCategory->getUrl();
}
ksort($subCategories[$category->getName()], SORT_STRING);
}
}
ksort($categories, SORT_STRING);
?>
-
<?php foreach ($categories as $name => $url): ?>
-
<?php echo $name; ?>
<?php
foreach ($subCategories as $key => $values) {
if($name == $key)
{
echo '
- ';
foreach($values as $subName => $subUrl)
{?>
- <?php echo $subName ?> <?php } echo "
<?php endforeach; ?>
Tuesday, 24 January 2012
Magento An error occurred while saving the URL rewrite
The line I commented out to actually get the indexer to work and finish was line 285 in app/code/core/Mage/Catalog/Model/Resource/URL.php
Before
Mage::logException($e);
Mage::throwException(Mage::helper('catalog')->__('An error occurred while saving the URL rewrite'));
After
//Mage::logException($e);
//Mage::throwException(Mage::helper('catalog')->__('An error occurred while saving the URL rewrite'));
I hope its work for you.
Monday, 28 November 2011
Add Date field with Datepicker in Magento Contact Form
Magento has a built in library for calendar functionalities. However the calendar library is available only on Admin pages like Custom Module, Customer Account view page, etc. We can extend the prototype Javascript library's calendar functions to frontend.
Edit the page.xml file in your current theme in the directory app/design/frontend/default/your-theme/layout/page.xml Around line 61 add the below lines in between
js_css calendar/calendar-win2k-1.css js calendar/calendar.js js calendar/calendar-setup.js
This will include the calendar library functions in the page head of all front end pages.
Now add Date Field to your contact form
Next step would be to add Javascript code at bottom of contact form template file. The id of the date input field and calendar image should be the same. The javascript code shown below should be added below the contact form coding.
Sunday, 27 November 2011
Magento Product Question
You wish to give users the option to quickly ask a question about a particular product then this simple extension will do the trick. This will present the user with a contact form with the product in question liked to at the top. You can download extension from here
Install the extension in the normal manner. To add the question you will need to edit your product page. Add the following where you wish to code to appear.
/app/design/frontend/default/your_theme/template/catalog/product/view.phtml
<?php if(Mage::getStoreConfigFlag('productquestion/productquestion/enabled')):
$url = $this->helper("productquestion")->getAddUrl($_product);
?>
<?php echo $this->__('Ask a question about this product') ?>
<?php endif; ?>
Tuesday, 15 November 2011
Magento: Getting product attributes values and labels
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'attribute_id');
foreach ( $attribute->getSource()->getAllOptions(true, true) as $option){
$attributeArray[$option['value']] = $option['label'];
}
I had a trickier time getting values for a multi-select attribute. I don't think that this is the best method, but it is one that worked for me. First the multi-select attribute must be set to be used in the advanced search. You can set this in the manage attributes area.
$attributes = Mage::getModel('catalogsearch/advanced')->getAttributes();
$attributeArray=array();
foreach($attributes as $a){
if($a->getAttributeCode() == 'desired_attribute_code'){
foreach($a->getSource()->getAllOptions(false) as $option){
$attributeArray[$option['value']] = $option['label'];
}
}
}
Here is a better way to get the multi-select attribute values.
$attributeId = Mage::getResourceModel('eav/entity_attribute')
->getIdByCode('catalog_product','attribute_code_here');
$attribute = Mage::getModel('catalog/resource_eav_attribute')
->load($attributeId);
$attributeOptions = $attribute ->getSource()->getAllOptions();
If you only need to retrieve a value for a product you can try this way
//Referenced from /app/code/core/Mage/Eav/Model/Config/php @ line 443
$_product->getResource()->getAttribute('club_type')
->getFrontend()->getValue($_product)
The code below will get an attribure collection. Set {entityType} to 4 to get attributes for products. You can remove the "setCodeFilters" line if you want to get all the attributes. To get anything really useful you will probably need to get the resulting attribute ids and do someting with them, like use them in a filter for the products collection or something.
$attributesInfo = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter({entityType})
->setCodeFilter($attributes)
->addSetInfo()
->getData();
Delete an attribute associated with a configurable product?
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
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
/path/to/app/checkout/cart/add?product=[id]&qty=[qty]
That URL is output by the template 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.
Processing...![]()
The function processNext() first updates the processing 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
<?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:
Just set the number in tags.8 bundle bundle/catalog_product_price bundle/catalog/product/price.phtml
Magento Cron error: /bin/sh: -c: line 0: syntax error near unexpected token `newline'
/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
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 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
Friday, 21 October 2011
Magento: this.images.toJSON is not a function
var myData = this.images.toJSON();
replace by:
var myData = $H(this.images).toJSON();
Thursday, 20 October 2011
Magento 1.5 admin - Categories are not appearing when editing products
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Categories.php
public function getSelectedCategoriesPathIds($rootId = false)
{
$ids = array();
$collection = Mage::getModel('catalog/category')->getCollection()
->addFieldToFilter('entity_id', array('in'=>$this->getCategoryIds()));
foreach ($collection as $item) {
if ($rootId && !in_array($rootId, $item->getPathIds())) {
continue;
}
foreach ($item->getPathIds() as $id) {
if (!in_array($id, $ids)) {
$ids[] = $id;
}
}
}
return $ids;
}
Wednesday, 19 October 2011
Remove “+$” or “-$” price value in the drop down in configurable product
change this line
'template' => str_replace('%s', '#{price}', $store->getCurrentCurrency()->getOutputFormat()),
'template' => Mage::helper('catalog')->__(''),
formatPrice: function(price, showSign){
var str = '';
price = parseFloat(price);
if(showSign){
if(price<0){
str+= '-';
price = -price;
}
else{
str+= '+';
}
}
TO
formatPrice: function(price, showSign){
var str = '';
price = parseFloat(price);
if(showSign){
if(price < 0){
str+= '';
price = -price;
}
else{
str+= '';
}
}

