Posts

Get Attribute Name And Value Magento

In magento you can create as many custom attributes  for your products as you want.Suppose you want to add or display brand color for every product on home, category or product page. So this is very easy to do with custom attributes. If we were to create a new custom attribute called “brand_color” and the attribute was of a “Text Field” type, we could do something like the following at a product level to obtain its value. 1 echo $_product ->getBrandColor(); ?> Get attribute collection 1 $attribute = $_product ->getResource()->getAttribute( 'my_attribute' ); ?> Get attribute type 1 $attribute = $_product ->getResource()->getAttribute( 'my_attribute' )->getAttributeType(); ?> Get attribute Label 1 $attribute = $_product ->getResource()->getAttribute( 'my_attribute' )->getFrontendLabel(); ?> Attribute is visible or not 1 $attribute = $_produc

Proportional Scaler (Image resize size caliculation, image ratio)

Ex:   step 1) Original Width = 900px;   step 2) Original Height = 300px;   step 3) Ratio = Original Width/Original Height   Step 4) Want Height from New Width (700px) a) New Height = New Width / Ratio OR   Step 4) Want Width from New Height (250px) a) New Width = New Height * Ratio

Magento get cart / quote info

Magento get cart/ quote info Method 1) $cartHelper = Mage::helper('checkout/cart'); $cartQty = $cartHelper->getItemsCount(); $items = $cartHelper->getCart()->getItems(); foreach ($items as $item) { echo $item->getItemId(); $product = Mage::getModel('catalog/product')->load($item->getProductId()); echo $product->getPublisher(); OR echo Mage::getModel('catalog/product')->load($_item->getProduct()->getId())->getAttributeText('manufacturer'); } Method 2) $cart = Mage::getModel('checkout/cart'); $ids = $cart->getProductIds(); print_r($ids); Method 3) $session = Mage::getSingleton('checkout/session'); $output = ""; foreach ($session->getQuote()->getAllItems() as $item) { $output .= 'id-->'.$item->getProductIds . " "; $output .= 'id-->'.$item->getItemId() . " "; $output .= 'sku-->'.$item->

MySQL Tips

1) Restore DB a) mysql --user=root --password=root maheshsql_db < "C:\mydbbkp.sql" 2) MYSQL Get all table rows and size of each table in DB a)   SELECT   table_schema   "Data Base Name" ,   SUM (   data_length   +   index_length )   /   1024   /   1024   "Data Base Size in MB"   FROM   information_schema . TABLES   GROUP   BY   table_schema ; b)   SELECT   TABLE_NAME ,   table_rows ,   data_length ,   index_length ,   round ((( data_length   +   index_length )   /   1024   /   1024 ), 2 )   "Size in MB"   FROM   information_schema . TABLES   WHERE   table_schema   =   "schema_name" ; c)   SELECT   SUM ( round ((( data_length   +   index_length )   /   1024   /   1024 ), 2 ))   "Size in MB"   FROM   information_schema . TABLES   WHERE   table_schema   =   "schema_name" ; 3) Count no of tables in DB a)   SELECT   count(*)   FROM   information_schema.tables   WHERE   table_schema     =   &