Last active
October 5, 2018 22:32
-
-
Save odahcam/bd77f3f4321f1d377bce2544689eec11 to your computer and use it in GitHub Desktop.
Function to retrieve a product SKU based on it's ID on Magento (1.8) platform.
This file contains hidden or 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 | |
include_once '../app/Mage.php'; | |
/** | |
* @author odahcam | |
* | |
* @version 1.0.0 | |
* | |
* @param {string|int} $product_id | |
* | |
* @return {string} | |
**/ | |
function getSkuById($product_id) | |
{ | |
$adapter = Mage::getSingleton('core/resource')->getConnection('core_read'); | |
$select = $adapter | |
->select() | |
->from(Mage::getResourceModel('catalog/product')->getEntityTable(), 'sku') | |
->where('entity_id = :entity_id'); | |
return $adapter->fetchOne($select, [':entity_id' => (string) $product_id]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment