Skip to content

Instantly share code, notes, and snippets.

@geekwho-eth
Created May 26, 2012 06:57
Show Gist options
  • Save geekwho-eth/2792657 to your computer and use it in GitHub Desktop.
Save geekwho-eth/2792657 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