protected function _prepareCollection() { //TODO: add full name logic $collection = AO::getResourceModel('reports/customer_collection')->addAttributeToSelect('firstname')->addAttributeToSelect('lastname'); $this->setCollection($collection); return parent::_prepareCollection(); }
protected function _prepareCollection() { $collection = AO::getResourceModel('reports/product_collection'); $collection->getEntity()->setStore(0); $this->setCollection($collection); return parent::_prepareCollection(); }
public function getAllOptions() { if (is_null($this->_options)) { $this->_options = AO::getResourceModel('core/store_collection')->load()->toOptionArray(); } return $this->_options; }
protected function _prepareCollection() { $collection = AO::getResourceModel('reports/wishlist_product_collection')->addAttributeToSelect('entity_id')->addAttributeToSelect('name')->addWishlistCount(); $this->setCollection($collection); parent::_prepareCollection(); return $this; }
protected function _prepareCollection() { $collection = AO::getResourceModel('admin/role_collection'); $collection->setRolesFilter(); $this->setCollection($collection); return parent::_prepareCollection(); }
public function getAllOptions() { if (!$this->_options) { $this->_options = AO::getResourceModel('directory/region_collection')->load()->toOptionArray(); } return $this->_options; }
public function load($printQuery = false, $logQuery = false) { $this->_select = $this->_read->select(); $entityTable = $this->getEntity()->getEntityTable(); $paidTable = $this->getAttribute('grand_total')->getBackend()->getTable(); $idField = $this->getEntity()->getIdFieldName(); $this->getSelect()->from(array('sales' => $entityTable), array('store_id', 'lifetime' => 'sum(sales.base_grand_total)', 'avgsale' => 'avg(sales.base_grand_total)', 'num_orders' => 'count(sales.base_grand_total)'))->where('sales.entity_type_id=?', $this->getEntity()->getTypeId())->group('sales.store_id'); if ($this->_customer instanceof Mage_Customer_Model_Customer) { $this->getSelect()->where('sales.customer_id=?', $this->_customer->getId()); } $this->printLogQuery($printQuery, $logQuery); try { $values = $this->_read->fetchAll($this->getSelect()->__toString()); } catch (Exception $e) { $this->printLogQuery(true, true, $this->getSelect()->__toString()); throw $e; } $stores = AO::getResourceModel('core/store_collection')->setWithoutDefaultFilter()->load()->toOptionHash(); if (!empty($values)) { foreach ($values as $v) { $obj = new Varien_Object($v); $storeName = isset($stores[$obj->getStoreId()]) ? $stores[$obj->getStoreId()] : null; $this->_items[$v['store_id']] = $obj; $this->_items[$v['store_id']]->setStoreName($storeName); $this->_items[$v['store_id']]->setAvgNormalized($obj->getAvgsale() * $obj->getNumOrders()); foreach ($this->_totals as $key => $value) { $this->_totals[$key] += $obj->getData($key); } } if ($this->_totals['num_orders']) { $this->_totals['avgsale'] = $this->_totals['lifetime'] / $this->_totals['num_orders']; } } return $this; }
protected function _prepareCollection() { //TODO: add full name logic $collection = AO::getResourceModel('sales/order_collection')->addAttributeToSelect('increment_id')->addAttributeToSelect('created_at')->addAttributeToSelect('grand_total')->addAttributeToSelect('order_currency_code')->addAttributeToSelect('store_id')->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id')->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id')->addAttributeToFilter('customer_id', AO::registry('current_customer')->getId()); $this->setCollection($collection); return parent::_prepareCollection(); }
public function save() { foreach ($this->getData() as $i => $row) { $this->setExceptionLocation('Line: ' . $i); $entity = AO::getResourceModel($this->getEntity()); if (!empty($row['entity_id'])) { try { $entity->load($row['entity_id']); $this->setPosition('Line: ' . $i . (isset($row['entity_id']) ? ', entity_id: ' . $row['entity_id'] : '')); } catch (Exception $e) { $this->addException(AO::helper('eav')->__('Problem loading a record, aborting. Error: %s', $e->getMessage()), Varien_Convert_Exception::FATAL); } if (!$entity->getId()) { $this->addException(AO::helper('eav')->__('Invalid entity_id, skipping the record'), Varien_Convert_Exception::ERROR); continue; } } try { $entity->addData($row)->save(); } catch (Exception $e) { $this->addException(AO::helper('eav')->__('Problem saving a record, aborting. Error: ', $e->getMessage()), Varien_Convert_Exception::FATAL); } } return $this; }
protected function _toHtml() { $rssObj = AO::getModel('rss/rss'); $order = AO::registry('current_order'); $title = AO::helper('rss')->__('Order # %s Notification(s)', $order->getIncrementId()); $newurl = AO::getUrl('sales/order/view', array('order_id' => $order->getId())); $data = array('title' => $title, 'description' => $title, 'link' => $newurl, 'charset' => 'UTF-8'); $rssObj->_addHeader($data); $resourceModel = AO::getResourceModel('rss/order'); $results = $resourceModel->getAllCommentCollection($order->getId()); $entityTypes = $resourceModel->getEntityTypeIdsToTypes(); $incrementIds = $resourceModel->getEntityIdsToIncrementIds(); if ($results) { foreach ($results as $result) { $urlAppend = 'view'; $type = $entityTypes[$result['entity_type_id']]; if ($type && $type != 'order') { $urlAppend = $type; } $title = AO::helper('rss')->__('Details for %s #%s', ucwords($type), $incrementIds[$result['parent_id']]); $description = '<p>' . AO::helper('rss')->__('Notified Date: %s<br/>', $this->formatDate($result['created_at'])) . AO::helper('rss')->__('Comment: %s<br/>', $result['comment']) . '</p>'; $url = AO::getUrl('sales/order/' . $urlAppend, array('order_id' => $order->getId())); $data = array('title' => $title, 'link' => $url, 'description' => $description); $rssObj->_addEntry($data); } } $title = AO::helper('rss')->__('Order #%s created at %s', $order->getIncrementId(), $this->formatDate($order->getCreatedAt())); $url = AO::getUrl('sales/order/view', array('order_id' => $order->getId())); $description = '<p>' . AO::helper('rss')->__('Current Status: %s<br/>', $order->getStatusLabel()) . AO::helper('rss')->__('Total: %s<br/>', $order->formatPrice($order->getGrandTotal())) . '</p>'; $data = array('title' => $title, 'link' => $url, 'description' => $description); $rssObj->_addEntry($data); return $rssObj->createRssXml(); }
public function getAllOptions() { if (!$this->_options) { $this->_options = AO::getResourceModel('tax/class_collection')->addFieldToFilter('class_type', 'CUSTOMER')->load()->toOptionArray(); } return $this->_options; }
public function toOptionArray() { if (!$this->_options) { $this->_options = AO::getResourceModel('cms/page_collection')->load()->toOptionArray(); } return $this->_options; }
protected function _prepareCollection() { //TODO: add full name logic $collection = AO::getResourceModel('sales/order_Creditmemo_collection')->addAttributeToSelect('increment_id')->addAttributeToSelect('created_at')->addAttributeToSelect('order_currency_code')->addAttributeToSelect('state')->addAttributeToSelect('grand_total')->joinAttribute('billing_firstname', 'order_address/firstname', 'billing_address_id', null, 'left')->joinAttribute('billing_lastname', 'order_address/lastname', 'billing_address_id', null, 'left')->joinAttribute('order_increment_id', 'order/increment_id', 'order_id', null, 'left')->joinAttribute('order_created_at', 'order/created_at', 'order_id', null, 'left'); $this->setCollection($collection); return parent::_prepareCollection(); }
protected function _prepareCollection() { $collection = AO::getResourceModel('reports/tag_product_collection'); $collection->addUniqueTagedCount()->addAllTagedCount()->addStatusFilter(AO::getModel('tag/tag')->getApprovedStatus())->addGroupByProduct(); $this->setCollection($collection); return parent::_prepareCollection(); }
public function __construct() { parent::__construct(); //TODO: add full name logic $orders = AO::getResourceModel('sales/order_collection')->addAttributeToSelect('*')->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left')->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left')->addAttributeToFilter('customer_id', AO::getSingleton('customer/session')->getCustomer()->getId())->addAttributeToFilter('state', array('in' => AO::getSingleton('sales/order_config')->getVisibleOnFrontStates()))->addAttributeToSort('created_at', 'desc')->setPageSize('5')->load(); $this->setOrders($orders); }
public function getOptionText($value) { if (!$value) { $value = '0'; } $isMultiple = false; if (strpos($value, ',')) { $isMultiple = true; $value = explode(',', $value); } if (!$this->_options) { $collection = AO::getResourceModel('core/store_collection'); if ('store_id' == $this->getAttribute()->getAttributeCode()) { $collection->setWithoutDefaultFilter(); } $this->_options = $collection->load()->toOptionArray(); if ('created_in' == $this->getAttribute()->getAttributeCode()) { array_unshift($this->_options, array('value' => '0', 'label' => AO::helper('customer')->__('Admin'))); } } if ($isMultiple) { $values = array(); foreach ($value as $val) { $values[] = $this->_options[$val]; } return $values; } else { return $this->_options[$value]; } return false; }
protected function _prepareCollection() { $collection = AO::getResourceModel('reports/product_collection')->addAttributeToSelect('name')->addAttributeToSelect('price')->setStoreId('')->addCartsCount()->addOrdersCount()->setSelectCountSqlType(Mage_Reports_Model_Mysql4_Product_Collection::SELECT_COUNT_SQL_TYPE_CART); /* @var $collection Mage_Reports_Model_Mysql4_Product_Collection */ $this->setCollection($collection); return parent::_prepareCollection(); }
public function _beforeToHtml() { $this->_currency = AO::getModel('directory/currency')->load(AO::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE)); $this->_collection = AO::getResourceModel('sales/sale_collection')->setCustomerFilter(AO::registry('current_customer'))->load(); $this->_groupedCollection = array(); foreach ($this->_collection as $sale) { if (!is_null($sale->getStoreId())) { $store = AO::app()->getStore($sale->getStoreId()); $websiteId = $store->getWebsiteId(); $groupId = $store->getGroupId(); $storeId = $store->getId(); $sale->setWebsiteId($store->getWebsiteId()); $sale->setWebsiteName($store->getWebsite()->getName()); $sale->setGroupId($store->getGroupId()); $sale->setGroupName($store->getGroup()->getName()); } else { $websiteId = 0; $groupId = 0; $storeId = 0; $sale->setStoreName(AO::helper('customer')->__('Deleted Stores')); } $this->_groupedCollection[$websiteId][$groupId][$storeId] = $sale; $this->_websiteCounts[$websiteId] = isset($this->_websiteCounts[$websiteId]) ? $this->_websiteCounts[$websiteId] + 1 : 1; } return parent::_beforeToHtml(); }
protected function _prepareCollection() { //TODO: add full name logic $collection = AO::getResourceModel('sales/order_shipment_collection')->addAttributeToSelect('increment_id')->addAttributeToSelect('created_at')->addAttributeToSelect('total_qty')->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left')->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left')->joinAttribute('order_increment_id', 'order/increment_id', 'order_id', null, 'left')->joinAttribute('order_created_at', 'order/created_at', 'order_id', null, 'left'); $this->setCollection($collection); return parent::_prepareCollection(); }
protected function _prepareCollection() { //TODO: add full name logic $collection = AO::getResourceModel('sales/order_shipment_collection')->addAttributeToSelect('increment_id')->addAttributeToSelect('created_at')->addAttributeToSelect('total_qty')->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left')->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left')->addExpressionAttributeToSelect('shipping_name', 'CONCAT({{shipping_firstname}}, " ", {{shipping_lastname}})', array('shipping_firstname', 'shipping_lastname'))->setOrderFilter($this->getOrder()); $this->setCollection($collection); return parent::_prepareCollection(); }
protected function _prepareLayout() { $isFilter = $this->getRequest()->getParam('store') || $this->getRequest()->getParam('website') || $this->getRequest()->getParam('group'); $collection = AO::getResourceModel('reports/order_collection')->calculateTotals($isFilter); if ($this->getRequest()->getParam('store')) { $collection->addAttributeToFilter('store_id', $this->getRequest()->getParam('store')); } else { if ($this->getRequest()->getParam('website')) { $storeIds = AO::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds(); $collection->addAttributeToFilter('store_id', array('in' => $storeIds)); } else { if ($this->getRequest()->getParam('group')) { $storeIds = AO::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds(); $collection->addAttributeToFilter('store_id', array('in' => $storeIds)); } } } $collection->load(); $collectionArray = $collection->toArray(); $totals = array_pop($collectionArray); $this->addTotal($this->__('Revenue'), $totals['revenue']); $this->addTotal($this->__('Tax'), $totals['tax']); $this->addTotal($this->__('Shipping'), $totals['shipping']); $this->addTotal($this->__('Quantity'), $totals['quantity'] * 1, true); }
protected function _prepareCollection() { $collection = AO::getResourceModel('catalogsearch/query_collection'); $this->setCollection($collection); parent::_prepareCollection(); return $this; }
protected function _prepareCollection() { $collection = AO::getResourceModel('reports/tag_product_collection'); $collection->addTagedCount()->addProductFilter($this->getRequest()->getParam('id'))->addStatusFilter(AO::getModel('tag/tag')->getApprovedStatus())->addStoresVisibility()->setActiveFilter()->addGroupByTag()->setRelationId(); $this->setCollection($collection); return parent::_prepareCollection(); }
protected function _prepareColumns() { $this->addColumn('entity_id', array('header' => AO::helper('customer')->__('ID'), 'width' => '50px', 'index' => 'entity_id', 'type' => 'number')); /*$this->addColumn('firstname', array( 'header' => AO::helper('customer')->__('First Name'), 'index' => 'firstname' )); $this->addColumn('lastname', array( 'header' => AO::helper('customer')->__('Last Name'), 'index' => 'lastname' ));*/ $this->addColumn('name', array('header' => AO::helper('customer')->__('Name'), 'index' => 'name')); $this->addColumn('email', array('header' => AO::helper('customer')->__('Email'), 'width' => '150', 'index' => 'email')); $groups = AO::getResourceModel('customer/group_collection')->addFieldToFilter('customer_group_id', array('gt' => 0))->load()->toOptionHash(); $this->addColumn('group', array('header' => AO::helper('customer')->__('Group'), 'width' => '100', 'index' => 'group_id', 'type' => 'options', 'options' => $groups)); $this->addColumn('Telephone', array('header' => AO::helper('customer')->__('Telephone'), 'width' => '100', 'index' => 'billing_telephone')); $this->addColumn('billing_postcode', array('header' => AO::helper('customer')->__('ZIP'), 'width' => '90', 'index' => 'billing_postcode')); $this->addColumn('billing_country_id', array('header' => AO::helper('customer')->__('Country'), 'width' => '100', 'type' => 'country', 'index' => 'billing_country_id')); $this->addColumn('billing_region', array('header' => AO::helper('customer')->__('State/Province'), 'width' => '100', 'index' => 'billing_region')); $this->addColumn('customer_since', array('header' => AO::helper('customer')->__('Customer Since'), 'type' => 'datetime', 'align' => 'center', 'index' => 'created_at', 'gmtoffset' => true)); if (!AO::app()->isSingleStoreMode()) { $websites = AO::getSingleton('adminhtml/system_store')->getWebsiteValuesForGridFilter(true, true); $this->addColumn('website_id', array('header' => AO::helper('customer')->__('Website'), 'align' => 'center', 'width' => '80px', 'type' => 'options', 'options' => $websites, 'index' => 'website_id')); } $this->addColumn('action', array('header' => AO::helper('customer')->__('Action'), 'width' => '100', 'type' => 'action', 'getter' => 'getId', 'actions' => array(array('caption' => AO::helper('customer')->__('Edit'), 'url' => array('base' => '*/*/edit'), 'field' => 'id')), 'filter' => false, 'sortable' => false, 'index' => 'stores', 'is_system' => true)); $this->addExportType('*/*/exportCsv', AO::helper('customer')->__('CSV')); $this->addExportType('*/*/exportXml', AO::helper('customer')->__('XML')); return parent::_prepareColumns(); }
protected function _prepareCollection() { //TODO: add full name logic $collection = AO::getResourceModel('sales/order_Creditmemo_collection')->addAttributeToSelect('increment_id')->addAttributeToSelect('created_at')->addAttributeToSelect('order_currency_code')->addAttributeToSelect('store_currency_code')->addAttributeToSelect('base_currency_code')->addAttributeToSelect('state')->addAttributeToSelect('grand_total')->addAttributeToSelect('base_grand_total')->joinAttribute('billing_firstname', 'order_address/firstname', 'billing_address_id', null, 'left')->joinAttribute('billing_lastname', 'order_address/lastname', 'billing_address_id', null, 'left')->addExpressionAttributeToSelect('billing_name', 'CONCAT({{billing_firstname}}, " ", {{billing_lastname}})', array('billing_firstname', 'billing_lastname'))->setOrderFilter($this->getOrder()); $this->setCollection($collection); return parent::_prepareCollection(); }
/** * Retrive invoices by filters * * @param array $filters * @return array */ public function items($filters = null) { //TODO: add full name logic $collection = AO::getResourceModel('sales/order_invoice_collection')->addAttributeToSelect('order_id')->addAttributeToSelect('increment_id')->addAttributeToSelect('created_at')->addAttributeToSelect('state')->addAttributeToSelect('grand_total')->addAttributeToSelect('order_currency_code')->joinAttribute('billing_firstname', 'order_address/firstname', 'billing_address_id', null, 'left')->joinAttribute('billing_lastname', 'order_address/lastname', 'billing_address_id', null, 'left')->joinAttribute('order_increment_id', 'order/increment_id', 'order_id', null, 'left')->joinAttribute('order_created_at', 'order/created_at', 'order_id', null, 'left'); $preparedFilters = array(); if (isset($filters->filter)) { foreach ($filters->filter as $_filter) { $preparedFilters[$_filter->key] = $_filter->value; } } if (isset($filters->complex_filter)) { foreach ($filters->complex_filter as $_filter) { $_value = $_filter->value; $preparedFilters[$_filter->key] = array($_value->key => $_value->value); } } if (!empty($preparedFilters)) { try { foreach ($preparedFilters as $field => $value) { if (isset($this->_attributesMap['invoice'][$field])) { $field = $this->_attributesMap['invoice'][$field]; } $collection->addFieldToFilter($field, $value); } } catch (Mage_Core_Exception $e) { $this->_fault('filters_invalid', $e->getMessage()); } } $result = array(); foreach ($collection as $invoice) { $result[] = $this->_getAttributes($invoice, 'invoice'); } return $result; }
protected function _prepareCollection() { $collection = AO::getResourceModel('googlebase/type_collection')->addItemsCount(); $this->setCollection($collection); parent::_prepareCollection(); return $this; }
public function getAllOptions() { if (!$this->_options) { $this->_options = AO::getResourceModel('customer/group_collection')->setRealGroupsFilter()->load()->toOptionArray(); } return $this->_options; }
public function getSharedCount() { $collection = AO::getResourceModel('customer/customer_collection'); $collection->getSelect()->from(array('wt' => $this->getWishlistTable()))->where('wt.customer_id=e.entity_id')->where('wt.shared=1')->group('wt.wishlist_id'); $collection->load(); return $collection->count(); }
public function toOptionArray($isMultiselect = false) { if (!$this->_options) { $countriesArray = AO::getResourceModel('directory/country_collection')->load()->toOptionArray(false); $this->_countries = array(); foreach ($countriesArray as $a) { $this->_countries[$a['value']] = $a['label']; } $countryRegions = array(); $regionsCollection = AO::getResourceModel('directory/region_collection')->load(); foreach ($regionsCollection as $region) { $countryRegions[$region->getCountryId()][$region->getId()] = $region->getDefaultName(); } uksort($countryRegions, array($this, 'sortRegionCountries')); $this->_options = array(); foreach ($countryRegions as $countryId => $regions) { $regionOptions = array(); foreach ($regions as $regionId => $regionName) { $regionOptions[] = array('label' => $regionName, 'value' => $regionId); } $this->_options[] = array('label' => $this->_countries[$countryId], 'value' => $regionOptions); } } $options = $this->_options; if (!$isMultiselect) { array_unshift($options, array('value' => '', 'label' => '')); } return $options; }