Created
April 9, 2016 07:29
-
-
Save yireo/b41ce88e51eb33e36a7b2c30a266823c to your computer and use it in GitHub Desktop.
Magento function to fetch Magento product SKU by ID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getSkuById($productId) | |
{ | |
$productResourceModel = Mage::getResourceModel('catalog/product'); | |
$adapter = Mage::getSingleton('core/resource')->getConnection('core_read'); | |
$select = $adapter->select() | |
->from($productResourceModel->getEntityTable(), 'sku') | |
->where('entity_id = :entity_id'); | |
$bind = array(':entity_id' => (string)$productId); | |
$productSku = $adapter->fetchOne($select, $bind); | |
return $productSku; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment