Skip to content

Instantly share code, notes, and snippets.

@bhapps
Forked from geekwho-eth/Magento code gist
Created January 1, 2016 00:28
Show Gist options
  • Save bhapps/61b5d9885b97ba504a7b to your computer and use it in GitHub Desktop.
Save bhapps/61b5d9885b97ba504a7b to your computer and use it in GitHub Desktop.
Magento code
<?php
//get import resource helper
$helper = Mage::getResourceHelper('importexport');
//get next auto increment id
$res = Mage::getSingleton('core/resource');
$readConnection = $res->getConnection('core_read');
$table = $res->getTableName('catalog_product_entity');
$id = Mage::getResourceHelper('importexport')->getNextAutoincrement("{$table}");
//Get product image
$attribute = 'small_image';//image、small_image、thumbnail
$this->helper('catalog/image')->init($product, $attribute)->resize(148, 113);
//get store base url
echo $_store->getBaseUrl('web');
//like http://www.xbc.me
echo $_store->getCurrenUrl();
//like http://www.xbc.me/index.php/?___store=default&___from_store=default
//cut string width magento style
Mage::helper('core/string')->truncate($string,$length);
//get current currency
Mage::helper('core')->currency($pr->getPrice());
//check magento attribte exists
//entity type code: customer customer_address catalog_category catalog_product order invioce creditmemo shipment
$_attribute = Mage::getModel('eav/entity_attribute')->getIdByCode('catalog_product', $attributeCode);
//get magento timestamp
$now = Mage::getModel('core/date')->timestamp(time());
//get default store
$defaultStore = Mage::app()->getDefaultStoreView()->getId();
$websiteId = Mage::getModel('core/store')->load($defaultStore)->getWebsiteId();
// get customer group ids
$customerGroups = Mage::getResourceModel('customer/group_collection')->toOptionHash();
$group_ids = implode(',', array_keys($customerGroups));
// format price
$formattedPrice = Mage::helper('core')->currency($_finalPrice,true,false);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment