Change default length of Increment ID for orders, invoices, shipments, creditmemos
By default in Magento CE 1.6, the default Increment ID of orders, invoices, shipments and creditmemos is 9 characters. If you want to make it short or long due to some other application dependency or whatever you will have to change the value of increment_pad_length in eav_entity_type table.
For changing it with some setup script installer, this code will do the trick:
$entityType = Mage::getModel('eav/entity_type')->loadByCode('order'); //invoice, shipment, creditmemo | |
$entityType->setIncrementPadLength(12)->save(); //changing length to 12 |
For changing it directly in database table, execute this queries:
UPDATE `eav_entity_type` SET `increment_pad_length`= 12 WHERE entity_type_code = 'order'; | |
UPDATE `eav_entity_type` SET `increment_pad_length`= 12 WHERE entity_type_code = 'invoice'; | |
UPDATE `eav_entity_type` SET `increment_pad_length`= 12 WHERE entity_type_code = 'shipment'; | |
UPDATE `eav_entity_type` SET `increment_pad_length`= 12 WHERE entity_type_code = 'creditmemo'; |
Magento: Can’t see product images in category page
Set product image as small image and thumbnail programatically
If you see your images in product detail page but don’t see it in category page, it’s because your product have images (image attribute filled) but not small_image and thumbnail which are required to display on category page. If there are only few products you want to set small_image and thumbnail, then it’s easy to go to Manage Products > Individual Product > Images tab > Set small image and thumbnail radio button. But when it comes to hundreds/thousands of products, you better want it programatically way.
Make a file in your Magento root and place the below code in it. Then run that file and you have just copied your Product Image to small image and thumbnail as well!
<?php | |
ini_set('display_errors',1); | |
require 'app/Mage.php'; | |
Mage::app(); | |
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*'); | |
foreach ($products as $product) { | |
if (!$product->hasImage()) continue; | |
if (!$product->hasSmallImage()) $product->setSmallImage($product->getImage()); | |
if (!$product->hasThumbnail()) $product->setThumbnail($product->getImage()); | |
$product->save(); | |
} | |
echo 'Finished!'; | |
?> |
Magento: Design Patterns
Factory:
It implement the concept of factories and deals with the problem of creating objects without specifying the exact class of object that will be created.
$product = Mage::getModel('catalog/product'); |
Singleton:
It restricts the instantiation of a class to one object. It will refer to same object each time called.
$category = Mage::getSingleton('catalog/session'); |
Registry:
It is a way to store information throughout your application.
Mage::register('key',$value); //stores | |
$currentCategory = Mage::registry('key'); //retrives |
Prototype:
It determines the type of object to create. In Magento it can be Simple, Configurable, Grouped, Bundle, Downloadable or Virtual types.
Mage:getModel('catalog/product')->getTypeInstance(); |
Observer:
It is mainly used to implement distributed event handling systems. Here the subject maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods.
Mage::dispatchEvent('event_name', array('key'=>$value)); |
<config> | |
<global> | |
<events> | |
<event_name> | |
<observers> | |
<unique_name> | |
<class>Class_Name</class> | |
<method>methodName</method> | |
</unique_name> | |
</observers> | |
</event_name> | |
</events> | |
</global> | |
</config> |
Magento: Product Free/Paid SAMPLE Purchase Order
If you want to allow your customers to order for sample of any product, before purchasing the actual product, it becomes very tough as in a product page you can’t have two products (sample + full) allowed. But it’s not a good idea to display sample products as Individually, it makes sense only in the actual product page just near the Add To Cart button.
But the question is, how to have TWO SKUs in a single product detail page? Here is the code that will do exactly what you want now. Open your catalog/product/view.phtml template file and put this code just below the code “$this->getChildHtml(‘addtocart’);”
<button type="button" style="float:left;padding-left:5px;" onclick="window.location.href='/order_sample.php?sku=<?php echo $this->htmlEscape($_product->getSku()) ?>'" title="Request Sample for < ?php echo $this->htmlEscape($_product->getName()) ?>" class="button btn-cart" ><span><span>Order Sample - $1</span></span></button> |
Magento: Product Import error – shows HTML code while importing
While importing products (somewhere around 1200 rows) by Magento’s in-built “System > Import/Export > Dataflow – Profiles” I got an error where the Dashboard’s HTML was printed in the output.
The reason for this error is due to something wrong in CSV product data which Magento didn’t understand. Create a temporary CSV file with only few rows (2-4) and check if that works. If it works, that means there is some problem with rest of the data.
For more information check my SO question here: http://stackoverflow.com/questions/14978970/magento-importing-product-error/14980974
Welcome to my Blog
Certifications
Honor
Recognition
Contributions
Categories
- Apache (2)
- ChatGPT (1)
- Domain name (2)
- eCommerce (2)
- htaccess (1)
- Humor (3)
- Instagram API (1)
- jQuery (4)
- JSON (1)
- Linux (10)
- Magento (142)
- Magento admin (58)
- Magento Certification (5)
- Magento error (13)
- Magento frontend (68)
- Magento Imagine (2)
- Magento Interview (5)
- Magento Master (2)
- Magento2 (10)
- Mobile (1)
- MySQL (7)
- OpenAI (1)
- OroCRM (2)
- Performance (2)
- PHP (8)
- Prototype JS (3)
- Security (4)
- Wordpress (3)
- XML (2)