[CODE] Get Product That Have “Expired” Special Price on Magento

Posted on Leave a commentPosted in Magento, PHP, Programming

$catalogCol= Mage::getModel(‘catalog/product’)->getCollection(); //get data for special price that expired $catalogCol->addAttributeToSelect(‘name’) ->addAttributeToSelect(‘price’) ->addAttributeToFilter(‘status’, array(‘eq’ => Mage_Catalog_Model_Product_Status::STATUS_ENABLED)) ->addAttributeToFilter(‘special_price’, array(‘gt’ => 0)) ->addAttributeToFilter(‘special_to_date’, array(‘date’ => true, ‘from’ => $todayDate, ‘to’ => $todayDate)); We can select what attribute that we need to be shown and then if we want to filter based on another attribute, we can use “addAttributeToFilter”.

[CODE] Get New Product on Magento

Posted on Leave a commentPosted in PHP, Programming

Below is code for get collection data that contain product with new SKU based on created data.. $catalogCol= Mage::getModel(‘catalog/product’)->getCollection(); //get data that new SKU product $catalogCol->addAttributeToSelect(‘name’) ->addAttributeToSelect(‘price’) ->addAttributeToFilter(‘status’, array(‘eq’ => Mage_Catalog_Model_Product_Status::STATUS_ENABLED)) ->addAttributeToFilter(‘created_at’, array(‘date’ => true, ‘from’ => $todayDate,’to’ => $date)); We can select what attribute that we need to be shown and then if we […]

Get URL base for Magento

Posted on Leave a commentPosted in Magento, Programming

This is the way to get URL base on Magento Frameworks [code] <?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); // output: http://yoursite.com/ echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS); // output: http://yoursite.com/js/ echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); // output: http://yoursite.com/index.php/ echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); // output: http://yoursite.com/media/ echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN); // output: http://yoursite.com/skin/</a> ?> [/code]

Magento connection adapter

Posted on Leave a commentPosted in Magento, Programming

Ketika kita ingin memasukkan data ke dalam database, Magento sudah mempermudah para developer dengan penggunaan Model dan Helper yang terdapat pada modul yang digunakan. Tapi kadang, sebagai developer kita sedikit malas untuk menyediakan class model dan helper yang diperlukan, untuk itu saya membuat custom code yang dapat digunakan secara lebih sederhana ketika ingin insert data […]