working on it ...
Explore Public Snippets
Found 11 snippets
Mage::getModel('plansetter/dailyscheduledraft') ->setId() ->setScheduleDate(Mage::getModel('core/date')->gmtDate(null, date("d-m-Y")))
public by fadzly 4362 0 5 0
Get magento locale date/time from GMT timestamp / current time
Get magento locale date/time from GMT timestamp / current time
date("d-m-Y H:i:s", Mage::getModel('core/date')->timestamp(time()))
<field> <label></label> <button_label>New Button</button_label> <frontend_model>mymodule/adminhtml_config_buttons_custombutton</frontend_model> <sort_order>3</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </field>
$$('div'); // -> all DIVs in the document. Same as document.getElementsByTagName('div'). // Nice addition, the elements you're getting back are already extended! $$('#contents'); // -> same as $('contents'), only it returns an array anyway (even though IDs must // be unique within a document). $$('li.faux'); // -> all LI elements with class 'faux' $$('#contents a[rel]'); // -> all links inside the element of ID "contents" with a rel attribute $$('a[href="#"]'); // -> all links with a href attribute of value "#" (eyeew!) $$('#navbar a', '#sidebar a'); // -> all links within the elements of ID "navbar" or "sidebar" $$('a:not([rel~=nofollow])'); // -> all links, excluding those whose rel attribute contains the word "nofollow" $$('table tbody > tr:nth-child(even)'); // -> all even rows within all table bodies $$('div:empty'); // -> all DIVs without content (i.e., whitespace-only)
protected function _prepareCollection() { //to join normal attributes; but not sku, type_id and others (see catalog_product_entity database table) $productAttributesArray = array('product_name' => 'name', 'product_seller' => 'seller', 'product_supplier' => 'supplier'); $poTempModel = Mage::getModel('mymodule/modelone')->load($this->getRequest()->getParam('id'),'actual_id'); $collection = Mage::getModel('mymodule/modeltwo')->getCollection()->addFieldToFilter('parent_id',$poTempModel->getId()); foreach ($productAttributesArray as $alias => $attributeCode) { $tableAlias = $attributeCode . '_table'; $attribute = Mage::getSingleton('eav/config')->getAttribute(Mage_Catalog_Model_Product::ENTITY, $attributeCode); //Add eav attribute value $collection->getSelect() ->joinLeft( array($tableAlias => $attribute->getBackendTable()), "main_table.product_id = $tableAlias.entity_id AND $tableAlias.attribute_id={$attribute->getId()}", array($alias => 'value') ); } //to join entity attributes such sku, type_id $collection->join( 'catalog/product', 'product_id = `catalog/product`.entity_id',//note the ` . DO NOT USE ' array('sku' => 'sku') ); $this->setCollection($collection); return parent::_prepareCollection(); } protected function _prepareColumns() { $this->addColumn('position', array( 'header'=> 'Position', 'width' => '50px', 'type' => 'number', 'index'=>'position', 'sortable' => false )); $this->addColumn('product_name', array( 'header'=> 'Name', 'type' => 'text', 'index'=>'product_name', 'sortable' => false )); $this->addColumn('sku', array( 'header'=> 'SKU', 'type' => 'text', 'index'=>'sku', 'sortable' => false )); $this->addColumn('poitemtemp_id', array( 'header'=> 'Action', 'align' => 'center', 'type' => 'number', 'index'=>'poitemtemp_id', 'renderer' => 'mymodule/adminhtml_editpo_elements_edit_gridscontainer_currentitemsrender', 'sortable' => false )); return parent::_prepareColumns(); }
Mage::getSingleton('adminhtml/session')->setAdminDeliveryTimeStart($timeStart); Mage::getSingleton('adminhtml/session')->unsAdminDeliveryTimeStart();
foreach($rawScheduleCollection as $key => $rawSchedule) { $scheduleObject = new Varien_Object(); $scheduleObject->setPosition($currentItemPosition); $scheduleObject->setTaskType($taskType); $scheduleObject->setTaskId($rawSchedule->getTaskId()); $scheduleObject->setCustomerName($rawSchedule->getCustomerName()); $scheduleObject->setCustomerTelephone($rawSchedule->getCustomerTelephone()); $scheduleObject->setTaskAddress($rawSchedule->getTaskAddress()); $scheduleObject->setTaskItem($rawSchedule->getTaskItem()); $scheduleObject->setTaskTime($rawSchedule->getTaskTime()); $scheduleObject->setScheduleItemRemarks($rawSchedule->getScheduleItemRemarks()); $scheduleObject->setAmtToCollect(number_format($itemTotalPrice, 2, '.', '')); $totalScheduleAmt += $itemTotalPrice; $processedScheduleCollection->addItem($scheduleObject); }
$catalog = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('catalog_setup'); $catalog->addAttribute('catalog_product','pickuprate', array( 'type' => 'int', 'input'=> 'select', 'label' => 'Pick Up Rate', 'user_defined' => 1, 'required' => 0, 'group'=> 'Prices', 'source' => 'Marketplace_Mod_Model_Pickuprategrp' ));
public function flushproductconfirmAction() { try { $data = $this->getRequest()->getPost(); $startDate = $data['startdate']; $endDate = $data['enddate']; $gmtStartDate = Mage::getModel('core/date')->gmtDate(null, strtotime(str_replace('/','-',$startDate))); $gmtEndDate = Mage::getModel('core/date')->gmtDate(null, strtotime(str_replace('/','-',$endDate))); $productBaseCostTbl = Mage::getSingleton('core/resource')->getTableName('inventorycost/productcost'); $mysql = "SELECT MAX(base_cost_id) base_cost_id, product_id, base_cost, date_added FROM frn_product_base_cost WHERE"; if(!empty($startDate)) { $mysql .= " date_added >= '".$gmtStartDate."'"; if(!empty($endDate)) { $mysql .= " AND date_added <= '".$gmtEndDate."'"; } } else { $mysql .= " date_added <= '".$gmtEndDate."'"; } $mysql .= " GROUP BY product_id"; $resource = Mage::getSingleton('core/resource'); $readConnection = $resource->getConnection('core_read'); $results = $readConnection->fetchAll($mysql); //Delete in frn_product_base_cost, frn_product_base_cost_current, frn_option_base_cost, frn_option_base_cost_current and product - start $totalProductsDelete = 0; foreach($results as $row) { $currentProduct = Mage::getModel('catalog/product')->load($row['product_id']); //Delete Options Cost - start foreach($currentProduct->getOptions() as $productOption) { if($productOption->getType() == 'radio' || $productOption->getType() == 'checkbox' || $productOption->getType() == 'drop_down') { $optionValues = $productOption->getValues(); foreach($optionValues as $tmpValue) { $tmpValueData = $tmpValue->getData(); //Delete option cost - start $optionCostCollection = Mage::getModel('inventorycost/optioncost') ->getCollection() ->addFieldToFilter('option_type_id',$tmpValueData['option_type_id']); foreach($optionCostCollection as $tmpOptionCost) { Mage::getModel('inventorycost/optioncost')->setId($tmpOptionCost->getId())->delete(); } //Delete option cost - end //Delete option cost current - start $optionCurrentCostCollection = Mage::getModel('inventorycost/optioncostcurrent') ->getCollection() ->addFieldToFilter('option_type_id',$tmpValueData['option_type_id']); foreach($optionCurrentCostCollection as $tmpCurrentOptionCost) { Mage::getModel('inventorycost/optioncostcurrent')->setId($tmpCurrentOptionCost->getId())->delete(); } //Delete option cost current - end } } } //Delete Options Cost - end //Delete Base Cost Current and Historical - start $productCostCollection = Mage::getModel('inventorycost/productcost')->getCollection() ->addFieldToFilter('product_id', $row['product_id']); foreach($productCostCollection as $tmpProductCost) { Mage::getModel('inventorycost/productcost')->setId($tmpProductCost->getId())->delete(); } $productCurrentCostCollection = Mage::getModel('inventorycost/productcostcurrent')->getCollection() ->addFieldToFilter('product_id', $row['product_id']); foreach($productCurrentCostCollection as $tmpProductCurrentCost) { Mage::getModel('inventorycost/productcostcurrent')->setId($tmpProductCurrentCost->getId())->delete(); } //Delete Base Cost Current and Historical - end //Set Product Cost to null - start $savedProductCost = $currentProduct->getCost(); if(!empty($savedProductCost)) { $currentProduct->setData('cost', null); } //Set Product Cost to null - end $totalProductsDelete++; } //Delete in frn_product_base_cost, frn_product_base_cost_current, frn_option_base_cost, frn_option_base_cost_current and product - end $response = array( 'error' => false, 'message' => $totalProductsDelete . " products had their costs deleted for dates : ".$startDate." to ".$endDate ); } catch(Exception $e) { $response = array( 'error' => true, 'message' => $e->getMessage() ); } $this->getResponse()->setHeader('Content-Type', 'application/json', true)->setBody(Mage::helper('core')->jsonEncode($response)); }
function generatereport() { var AjaxURL = "<?php echo $this->getURL('inventorycostadmin/adminhtml_report/generateestgrprofitcogs');?>"; AjaxURL = AjaxURL + (AjaxURL.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true'); new Ajax.Request(AjaxURL, { parameters: {querystr: "<?php echo $newQuery; ?>"}, onSuccess: function(valueinfo) { if (valueinfo.responseText.isJSON()) { var response = valueinfo.responseText.evalJSON(); if (response.error) { alert(response.message); } else { $('reportdiv').update('<b>Total Gross Profit for filtered period : </b>'+response.formattedgrossprofit+'<br><b>Total Cost of Goods Sold for filtered period : </b>'+response.formattedcostofgoodssold+'<br><b>Total Sales for filtered period : </b>'+response.formattedgoodssoldprice); } } } }); }