Tuesday, November 29, 2011

Magento Product ID and Attribute value


How to get all the ID of product in one page

$model = Mage::getModel('catalog/product'); //getting product model

$collection = $model->getCollection(); //products collection

foreach ($collection as $product) //loop for getting products
{
    echo $product->getId();

}

How to get the attribute value of any attribute name in any page 

$_Products = Mage::getSingleton('checkout/cart')->getQuote()->getAllItems();

foreach ($_Products as $value){

$item_ID = $value->getProductId();

$_Product = Mage::getModel('catalog/product')->load($item_ID);

$checkfree = $_Product->getAttributeText('your_attribute_code');

echo $checkfree; //to getthe attribute value of free shipping

}

Sunday, November 27, 2011

Magento MVC

MVC(Model view Controller)

Model(M):As the name refer Model which will store the businees logic i.e database connection or connection to datasources.Magento uses the model folder for every module whether it is in core,local,community

View(C):The view refer to presentaion logic i.e templating and caching  which will display to the end user.Magento having .phtml and with help of Xml it produce output to the user

Controllers(C): Controller are the  iles which decides the actions between model and view files what output to be generated these files are under controller folder and manages the url structure for magento.In magento if you will not define the Controller it will redirect to 404 page.

In Simple way to understand the MVC take example CAR

Model: Other Input from the Model

View :Interior and Exterior features of the car

Controller: Input from the user like applying break,staring,horn etc...

Magento: Attribute feature

Magento Class Instances  and Attribute Value
  1. getData = Relevant Data from object
  2. getSingleton = If you are using getSingleton you are calling already instance object
  3. getModel = Instance of Class Ex: $product = Mage::getModel('catalog/product');
  4. getChildHtml = Calling Block of Block of Block
  5. $attribute = $_product->getResource()->getAttribute('your_attribute_id'); (Get Attribute Collection) 
  6. $attribute->getAttributeType()  (Get Attribute type)
  7. $attribute->getFrontendLabel()  (Get Attribute Label)
  8. $attribute->getDefaultValue()    (Get Attribute Value)
  9. $attribute->getIsVisible()          (Get Attribute is Visible)    
  10. $attribute->getIsRequired()      (Get Attribute is Required)

Magento Related

Resource Model
$resource = Mage::getSingleton('core/resource');

Read Connection
$read = $resource->getConnection('core_read');

Write Connection
$write = $resource->getConnection('core_write');

Get Table Name
$table = $resource->getTableName('catalog_product_entity');

Get Table Name from Entity Name
$table = $resource->getTableName('catalog/product');

Friday, November 25, 2011

Magento Model Collection

Magento data collection inhert from the object
public function productAction()
{
$collection_of_products = Mage::getModel('catalog/product')->getCollection();
var_dump($collection_of_products->getFirstItem()->getData());
}

Most Magento Model objects have a method named getCollection which will return a collection that, by default, is initialized to return every Object of that type in the system.

The products Collection, as well as many other Magento Collections, also have the Varien_Data_Collection_Db class in their ancestor chain if you want to see the select statement your Collection is using

Magento upgrade through Magento connect


Following are the steps for upgrading from Magento 1.5.1.0 to this latest version of magento (Via Connect Manager):

  1. Open Magento Connect Manager by navigating to System > Magento Connect > Magento Connect Manager.
  2. After that fill your username and password used to access the admin panel.
  3. Click check for upgrades in Magento Connect Manager  
  4. As soon as the search for upgrades would finish, the “Upgrade to 1.5.1.0.1” will be listed for the Mage_All_Latest package in the Available column.
  5. Select “Upgrade to 1.5.1.0.1” in the Actions column for the Mage_All_Latest package and click “Commit Changes”.
  6. Package Mage_All_Latest Actions column, select “Last 1.5.1.0.1″ and click OK the changes.
  7. Make sure whether the package upgrades installed successfully or not by viewing messages on the console.
  8. Click the refresh button in the console window.
  9. Go to the Settings at the top.

Magneto Upgrade

Now Upgrading Magneto became easy

Note: If you want to upgrade Magento from 1.3 to 1.6 or 1.4 to 1.6 or 1.5 to 1.6 follow the same procedure

Follow the steps

Thursday, November 24, 2011

Magento Certification

Good Opportunity for the developer. Magento Launches the Certification Course.Now getting certification is much easier for the developer.Just register yourself and get certified.

Register Now – Space is Limited

Sign up today to take the Magento Certified Developer exam.

If any queries related to the Certification you can just email to training@magento.com

Show one single customer review

Showing latest and one review now quit easy
Go to review > product > list.phtml
Replace the code in that file with this

Product Reviews on Product View Page

Magento had functionality for showing the reviews in review page .Now it is Easy way to get the Product Reviews on Product View Page Add the follwing code in

Add the review blocks to the correct XML reference in catalog.xml which is in app > design > frontend > default > yourtheme > layout

Wednesday, November 23, 2011

How to get current currency and Symbol

To get Current Currency

$currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();   

To get current currency symbol use:

Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();

How to print all queries in Magneto

How to print all queries in Magneto Became simple

Follow the steps as per instruction

Note: Make sure that you will add the above code in local folder and back up your database

1) Open the Magento your version : lib/varien/Db/Adapter/Pdo/Mysql.php

2) Make the above setting as Yes
  protected $_debug               = true;
 protected $_logAllQueries       = true;

3)protected $_debugFile           = 'var/debug/sql.txt';

4)if it is already there then don't follow step(3)

5)Now open the local.xml and add the following code

below resources/default_setup/connection/
<profiler> 1< profiler>

6)Now open any template file or php file and add the following
$profiler = Mage::getSingleton('core/resource')->getConnection('core_write')->getProfiler();
To simply output all queries:

print_r($profiler); and check the var/debug/ folder you will get the all the selected query.

Tuesday, November 22, 2011

Magento Training session

Now learning Magento became easy.Magento launches the Training session for the developer to make it Easier Faster to learn Magento.
Easy step to join the Training session
Just click on the following link http://www.magentocommerce.com/services/register-for-training
and Register your self with the course in which you are interested

LinkWithin

Blog has moved, searching new blog...