Posts

Showing posts from 2012

MAGENTO, How to find Product Tax Rate OR Tax Percentage

## MAGENTO, How to find Product tax rate foreach ($productIds as $productId) { $_product = Mage::getModel('catalog/product')->load($productId); $productsPrice = floatval($_product->getData("price")); // Get the product's tax class' ID $taxClassId = $_product->getData("tax_class_id"); echo 'Tax Class ID '.$taxClassId.' '; // Get the tax rates of each tax class in an associative array $taxClasses = Mage::helper("core")->jsonDecode( Mage::helper("tax")-         >getAllRatesByProductClass() ); echo  'Tax Classes '.$taxClasses.' '; // Extract the tax rate from the array $taxRate = $taxClasses["value_".$taxClassId]; echo 'Tax Rate '.$taxRate.' '; } ?>

Lok Satta Videos: Short Film for Surajya Udyamam

Lok Satta Videos: Short Film for Surajya Udyamam

PHP Function to Create URLs

$url = 'http://maheshbokkisam.blogspot.com/create_url.php'; $data = array("a"=>1, "b"=>3, "c"=>''); _make_url($url, $data); /**    * Create url with url and uri    * @param url and uri data (array)  * return string (url)   */ function _make_url($url='http://'.$_SERVER['SERVER_NAME'], $data){ $data = array_diff($data, array(''=>''));                // remove empty keys from uri data array                return (count($data) > 0) ? $url.'?'.http_build_query($data, 'flags_') : $url; }

MAGENTO::Sales Order Grid Customization - Add SKU list and customer email column to the grid

Add SKU list and Customer Email column to the grid Supposed you had copied your code\core\Mage\Adminhtml\Block\Sales\Order\Grid.php to code\local\Mage\Adminhtml\Block\Sales\Order\Grid.php because you want to display the subtotals, credit card types, total of items ordered for the sales order. The new version of Magento which is 1.4.1 in code\local\Mage\Adminhtml\Block\Sales\Order\Grid.php change like this protected function _prepareCollection() { $collection = Mage::getResourceModel($this->_getCollectionClass()); $collection->getSelect()->joinLeft( array('sfoi'=>'sales_flat_order_item'), 'main_table.entity_id=sfoi.order_id', array( 'sku' =>'sfoi.sku' ) ); $collection->addExpressionFieldToSelect ( "sku", "GROUP_CONCAT(sku SEPARATOR ' , ')", $fields="" ); $collection->getSelect()->group("entity_id"); $collection->getSelect()->join

FORM 16 - small company - Fresher - IT (Income Tax) returns - TDS

Hi If you are fresher and you got a job in a company, first verify with company is they fill your IT (Income Tax) returns. Why Because in future the IT returns are very useful, For example 1) If you want apply for any loans 2) If you want apply for VISA. etc... NOTE: If you are under tax limitation or not your company should fill you TDS form.

Magento Get flatrate_shipping_subtotal, free_shipping_subtotal and flatrate_price/ Shipping Price

Get the flat rate and shipping subtotal price in Magento pages. $flatrateShippingSubtotal = Mage::getStoreConfig('carriers/flatrate/flatrate_shipping_subtotal'); $freeShippingSubtotal = Mage::getStoreConfig('carriers/freeshipping/free_shipping_subtotal'); $shippingCharges = Mage::getStoreConfig('carriers/flatrate/price');

Magento: Getting product attributes values and labels

I have found that it is very useful to be able to get attributes from the system and use them in places other than a products category page. I always forget the exact syntax to use so, this is going to be my unofficial cheat sheet. This is how to get a drop down lists options. I don’t think it will work for a mulit-select attribute. I stick the value/label pairs into an array to use how I please. $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('catalo

Magento Get product description from product Id

Magento: Get the product description in catalog/category list page /** * Get the resource model */ $resource = Mage::getSingleton('core/resource'); /** * Retrieve the read connection */ $readConnection = $resource->getConnection('core_read'); /** * Retrieve our table name */ $table   =   $resource->getTableName('catalog_product_entity_text'); $query  =   "SELECT value FROM {$table} WHERE entity_id = ". (int)$_product->getId(); //print_r(get_class_methods($readConnection)) ; /** * Execute the query */ // $readConnection->query($query); $results   =   $readConnection->fetchAll($query); /* straight dump to screen without formatting */ //print_r($results); $description = $results[0]['value']; ?>

Get distinct value, show multiple row values in one column

If there is a table called userList userid       listid ----------      ------------- 1               2 2               2 1               2 1               1 2               1 2 3 2 1 Result I expected was: userid       listid ----------      ------------- 1               1,2,2 2               1,1,2,3 SELECT userid, GROUP_CONCAT(DI STINCT listid ORDER BY listid ASC SEPARATOR ',') FROM mahesh GROUP BY userid; Table Used : CREATE TABLE IF NOT EXISTS `mahesh` (   `userid` int(11) NOT NULL,   `listid` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `mahesh` (`userid`, `listid`) VALUES (1, 2), (2, 2), (1, 2), (1, 1), (2, 1), (2, 3), (2, 1);

SQL objects

SQL objects are 1) schemas, 2) data dictionaries,  3) journals, 4) catalogs,  5) tables,  6) aliases,  7) views,  8) indexes,  9) constraints,  10) triggers,  11) sequences,  12) stored procedures,  14) user-defined functions,  15) user-defined types,  16) and SQL packages. SQL creates and maintains these objects as system objects.  A brief description of these objects follows :

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