public function addWishlistCount() { $wishlistItemTable = AO::getSingleton('core/resource')->getTableName('wishlist/item'); $this->getSelect()->from(array('wi' => $wishlistItemTable), 'count(wishlist_item_id) as wishlists')->where('wi.product_id=e.entity_id')->group('wi.product_id'); $this->getEntity()->setStore(0); return $this; }
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 getTotalReviews() { if (!$this->getTotalReviewsCache()) { $this->setTotalReviewsCache(AO::getModel('review/review')->getTotalReviews($this->getProductData()->getId(), false, AO::app()->getStore()->getId())); } return $this->getTotalReviewsCache(); }
public function getErrorMessage() { if (!$this->getData('error_message')) { $this->setData('error_message', AO::helper('shipping')->__('This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.')); } return $this->getData('error_message'); }
public function __construct() { $this->_controller = 'system_convert_profile'; $this->_headerText = AO::helper('adminhtml')->__('Advanced Profiles'); $this->_addButtonLabel = AO::helper('adminhtml')->__('Add New Profile'); parent::__construct(); }
/** * Returns Google Base recommended Item Types * * @param string $targetCountry Two-letters country ISO code * @return array */ public function getItemTypes($targetCountry) { $locale = AO::getSingleton('googlebase/config')->getCountryInfo($targetCountry, 'locale'); $location = self::ITEM_TYPES_LOCATION . '/' . $locale; $feed = $this->getGuestService()->getFeed($location); $itemTypes = array(); foreach ($feed->entries as $entry) { $type = $entry->extensionElements[0]->text; $item = new Varien_Object(); $item->setId($type); $item->setName($entry->title->text); $item->setLocation($entry->id->text); $itemTypes[$type] = $item; $typeAttributes = $entry->extensionElements[1]->extensionElements; $attributes = array(); if (is_array($typeAttributes)) { foreach ($typeAttributes as $attr) { $name = $attr->extensionAttributes['name']['value']; $type = $attr->extensionAttributes['type']['value']; $attribute = new Varien_Object(); $attribute->setId($name); $attribute->setName($name); $attribute->setType($type); $attributes[$name] = $attribute; } } ksort($attributes); $item->setAttributes($attributes); } ksort($itemTypes); $this->_itemTypes = $itemTypes; return $itemTypes; }
public function __construct() { parent::__construct(); $this->setTemplate('widget/view/container.phtml'); $this->_addButton('back', array('label' => AO::helper('adminhtml')->__('Back'), 'onclick' => 'window.location.href=\'' . $this->getUrl('*/*/') . '\'', 'class' => 'back')); $this->_addButton('edit', array('label' => AO::helper('adminhtml')->__('Edit'), 'class' => 'edit', 'onclick' => 'window.location.href=\'' . $this->getEditUrl() . '\'')); }
/** * Get tier prices (formatted) * * @param Mage_Catalog_Model_Product $product * @return array */ public function getTierPrices($product = null) { if (is_null($product)) { $product = $this->getProduct(); } $prices = $product->getFormatedTierPrice(); $res = array(); if (is_array($prices)) { foreach ($prices as $price) { $price['price_qty'] = $price['price_qty'] * 1; if ($product->getPrice() != $product->getFinalPrice()) { $productPrice = $product->getFinalPrice(); } else { $productPrice = $product->getPrice(); } if ($price['price'] < $productPrice) { $price['savePercent'] = ceil(100 - 100 / $productPrice * $price['price']); $price['formated_price'] = AO::app()->getStore()->formatPrice(AO::app()->getStore()->convertPrice(AO::helper('tax')->getPrice($product, $price['website_price']))); $price['formated_price_incl_tax'] = AO::app()->getStore()->formatPrice(AO::app()->getStore()->convertPrice(AO::helper('tax')->getPrice($product, $price['website_price'], true))); $res[] = $price; } } } return $res; }
protected function _joinFields() { $tagTable = AO::getSingleton('core/resource')->getTableName('tag/tag'); $tagRelationTable = AO::getSingleton('core/resource')->getTableName('tag/relation'); $this->addAttributeToSelect('name'); $this->getSelect()->join(array('relation' => $tagRelationTable), "relation.product_id = e.entity_id")->join(array('t' => $tagTable), "t.tag_id =relation.tag_id", array('tag_id', 'status', 'tag_name' => 'name')); }
public function saveRel(Mage_Admin_Model_Rules $rule) { $this->_getWriteAdapter()->beginTransaction(); try { $roleId = $rule->getRoleId(); $this->_getWriteAdapter()->delete($this->getMainTable(), "role_id = {$roleId}"); $masterResources = AO::getModel('admin/roles')->getResourcesList2D(); $masterAdmin = false; if ($postedResources = $rule->getResources()) { foreach ($masterResources as $index => $resName) { if (!$masterAdmin) { $permission = in_array($resName, $postedResources) ? 'allow' : 'deny'; $this->_getWriteAdapter()->insert($this->getMainTable(), array('role_type' => 'G', 'resource_id' => trim($resName, '/'), 'privileges' => '', 'assert_id' => 0, 'role_id' => $roleId, 'permission' => $permission)); } if ($resName == 'all' && $permission == 'allow') { $masterAdmin = true; } } } $this->_getWriteAdapter()->commit(); } catch (Mage_Core_Exception $e) { throw $e; } catch (Exception $e) { $this->_getWriteAdapter()->rollBack(); } }
function initForm() { $model = AO::registry('oscommerce_adminhtml_import'); $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post')); if ($model->getId()) { $form->addField('import_id', 'hidden', array('name' => 'import_id')); } $fieldset = $form->addFieldset('base_fieldset', array('legend' => AO::helper('oscommerce')->__('General Information'))); $fieldset->addField('name', 'text', array('label' => $this->__('Name'), 'title' => $this->__('Name'), 'name' => 'name', 'required' => true)); $fieldset->addField('host', 'text', array('label' => $this->__('IP or Hostname'), 'title' => $this->__('IP or Hostname'), 'name' => 'host', 'required' => true)); // $fieldset->addField('port', 'text', array( // 'label' => $this->__('Port (Default as 3306)'), // 'title' => $this->__('Port (Default as 3306)'), // 'name' => 'port', // 'required' => true, // 'value' => $model->getData('port') ? $model->getData('port'): Mage_Oscommerce_Model_Oscommerce::DEFAULT_PORT // )); $fieldset->addField('db_name', 'text', array('label' => $this->__('DB Name'), 'title' => $this->__('DB Name'), 'name' => 'db_name', 'required' => true)); $fieldset->addField('db_user', 'text', array('label' => $this->__('DB Username'), 'title' => $this->__('DB Username'), 'name' => 'db_user', 'required' => true)); $fieldset->addField('db_password', 'password', array('label' => $this->__('DB Password'), 'title' => $this->__('DB Password'), 'name' => 'db_password')); $fieldset->addField('table_prefix', 'text', array('label' => $this->__('Prefix'), 'title' => $this->__('Prefix'), 'name' => 'table_prefix')); $fieldset->addField('send_subscription', 'checkbox', array('label' => $this->__('Send subscription notify to customers'), 'title' => $this->__('Send subscription notify to customers'), 'name' => 'send_subscription', 'values' => $this->getData('send_subscription'), 'checked' => $this->getData('send_subscription'))); $form->setValues($model->getData()); $this->setForm($form); return $this; }
public function getUrl($params = array()) { static $reservedKeys = array('module' => 1, 'controller' => 1, 'action' => 1, 'array' => 1); if (is_string($params)) { $paramsArr = explode('/', $params); $params = array('controller' => $paramsArr[0], 'action' => $paramsArr[1]); } $url = AO::getBaseUrl($params); if (!empty($params['frontName'])) { $url .= $params['frontName'] . '/'; } else { $url .= $this->_config->getName() . '/'; } if (!empty($params)) { $paramsStr = ''; foreach ($params as $key => $value) { if (!isset($reservedKeys[$key]) && '_' !== $key[0] && !empty($value)) { $paramsStr .= $key . '/' . $value . '/'; } } if (empty($params['controller']) && !empty($paramsStr)) { $params['controller'] = 'index'; } $url .= empty($params['controller']) ? '' : $params['controller'] . '/'; if (empty($params['action']) && !empty($paramsStr)) { $params['action'] = 'index'; } $url .= empty($params['action']) ? '' : $params['action'] . '/'; $url .= $paramsStr; $url .= empty($params['array']) ? '' : '?' . http_build_query($params['array']); } return $url; }
public function __construct() { $this->_controller = 'report_customer_totals'; $this->_headerText = AO::helper('reports')->__('Customers by orders total'); parent::__construct(); $this->_removeButton('add'); }
public function getResource() { if (!$this->_resource) { $this->_resource = AO::getResourceSingleton('catalog_entity/convert'); } return $this->_resource; }
public function __construct() { $this->_controller = 'api_role'; $this->_headerText = AO::helper('adminhtml')->__('Roles'); $this->_addButtonLabel = AO::helper('adminhtml')->__('Add New Role'); parent::__construct(); }
/** * Add order items count expression * * @return Mage_Sales_Model_Mysql4_Order_Collection */ public function addItemCountExpr() { $orderTable = $this->getEntity()->getEntityTable(); $orderItemEntityTypeId = AO::getResourceSingleton('sales/order_item')->getTypeId(); $this->getSelect()->join(array('items' => $orderTable), 'items.parent_id=e.entity_id and items.entity_type_id=' . $orderItemEntityTypeId, array('items_count' => new Zend_Db_Expr('COUNT(items.entity_id)')))->group('e.entity_id'); return $this; }
/** * Get layer state key * * @return string */ public function getStateKey() { if ($this->_stateKey === null) { $this->_stateKey = 'Q_' . AO::helper('catalogSearch')->getQuery()->getId() . '_' . parent::getStateKey(); } return $this->_stateKey; }
public function __construct() { $this->_controller = 'report_sales_coupons'; $this->_headerText = AO::helper('reports')->__('Coupons'); parent::__construct(); $this->_removeButton('add'); }
public function render(Varien_Object $row) { if (!$row->getData($this->getColumn()->getIndex())) { return null; } return '<a title="' . AO::helper('core')->__('Edit Store') . '" href="' . $this->getUrl('*/*/editGroup', array('group_id' => $row->getGroupId())) . '">' . $row->getData($this->getColumn()->getIndex()) . '</a>'; }
public function __construct() { parent::__construct(AO::getSingleton('core/resource')->getConnection('admin_read')); $this->_roleTable = AO::getSingleton('core/resource')->getTableName('admin/role'); $this->_select->from($this->_roleTable); $this->setItemObjectClass(AO::getConfig()->getModelClassName('admin/acl_role')); }
protected function _toHtml() { if (!$this->_beforeToHtml() || !AO::getStoreConfig('dev/debug/profiler') || !AO::helper('core')->isDevAllowed()) { return ''; } $timers = Varien_Profiler::getTimers(); #$out = '<div style="position:fixed;bottom:5px;right:5px;opacity:.1;background:white" onmouseover="this.style.opacity=1" onmouseout="this.style.opacity=.1">'; #$out = '<div style="opacity:.1" onmouseover="this.style.opacity=1" onmouseout="this.style.opacity=.1">'; $out = "<a href=\"javascript:void(0)\" onclick=\"\$('profiler_section').style.display=\$('profiler_section').style.display==''?'none':''\">[profiler]</a>"; $out .= '<div id="profiler_section" style="background:white; display:block">'; $out .= '<pre>Memory usage: real: ' . memory_get_usage(true) . ', emalloc: ' . memory_get_usage() . '</pre>'; $out .= '<table border="1" cellspacing="0" cellpadding="2" style="width:auto">'; $out .= '<tr><th>Code Profiler</th><th>Time</th><th>Cnt</th><th>Emalloc</th><th>RealMem</th></tr>'; foreach ($timers as $name => $timer) { $sum = Varien_Profiler::fetch($name, 'sum'); $count = Varien_Profiler::fetch($name, 'count'); $realmem = Varien_Profiler::fetch($name, 'realmem'); $emalloc = Varien_Profiler::fetch($name, 'emalloc'); if ($sum < 0.001 && $count < 10 && $emalloc < 10000) { continue; } $out .= '<tr>' . '<td align="left">' . $name . '</td>' . '<td>' . number_format($sum, 4) . '</td>' . '<td align="right">' . $count . '</td>' . '<td align="right">' . number_format($emalloc) . '</td>' . '<td align="right">' . number_format($realmem) . '</td>' . '</tr>'; } $out .= '</table>'; $out .= '<pre>'; $out .= print_r(Varien_Profiler::getSqlProfiler(AO::getSingleton('core/resource')->getConnection('core_write')), 1); $out .= '</pre>'; $out .= '</div>'; return $out; }
protected function _prepareForm() { if (!$this->_form) { $this->_form = new Varien_Data_Form(); $fieldset = $this->_form->addFieldset('main', array('no_container' => true)); $addressModel = AO::getModel('customer/address'); foreach ($addressModel->getAttributes() as $attribute) { if (!$attribute->getIsVisible()) { continue; } if ($inputType = $attribute->getFrontend()->getInputType()) { $element = $fieldset->addField($attribute->getAttributeCode(), $inputType, array('name' => $attribute->getAttributeCode(), 'label' => $this->__($attribute->getFrontend()->getLabel()), 'class' => $attribute->getFrontend()->getClass(), 'required' => $attribute->getIsRequired()))->setEntityAttribute($attribute); if ($inputType == 'select' || $inputType == 'multiselect') { $element->setValues($attribute->getFrontend()->getSelectOptions()); } } } if ($regionElement = $this->_form->getElement('region')) { $regionElement->setRenderer($this->getLayout()->createBlock('adminhtml/customer_edit_renderer_region')); } if ($regionElement = $this->_form->getElement('region_id')) { $regionElement->setNoDisplay(true); } $this->_form->setValues($this->getFormValues()); } return $this; }
public function getLinksTitle() { if ($this->_purchased->getLinkSectionTitle()) { return $this->_purchased->getLinkSectionTitle(); } return AO::getStoreConfig(Mage_Downloadable_Model_Link::XML_PATH_LINKS_TITLE); }
protected function _prepareForm() { $model = AO::registry('api_user'); $form = new Varien_Data_Form(); $form->setHtmlIdPrefix('user_'); $fieldset = $form->addFieldset('base_fieldset', array('legend' => AO::helper('adminhtml')->__('Account Information'))); if ($model->getUserId()) { $fieldset->addField('user_id', 'hidden', array('name' => 'user_id')); } else { if (!$model->hasData('is_active')) { $model->setIsActive(1); } } $fieldset->addField('username', 'text', array('name' => 'username', 'label' => AO::helper('adminhtml')->__('User Name'), 'id' => 'username', 'title' => AO::helper('adminhtml')->__('User Name'), 'required' => true)); $fieldset->addField('firstname', 'text', array('name' => 'firstname', 'label' => AO::helper('adminhtml')->__('First Name'), 'id' => 'firstname', 'title' => AO::helper('adminhtml')->__('First Name'), 'required' => true)); $fieldset->addField('lastname', 'text', array('name' => 'lastname', 'label' => AO::helper('adminhtml')->__('Last Name'), 'id' => 'lastname', 'title' => AO::helper('adminhtml')->__('Last Name'), 'required' => true)); $fieldset->addField('email', 'text', array('name' => 'email', 'label' => AO::helper('adminhtml')->__('Email'), 'id' => 'customer_email', 'title' => AO::helper('adminhtml')->__('User Email'), 'class' => 'required-entry validate-email', 'required' => true)); if ($model->getUserId()) { $fieldset->addField('password', 'password', array('name' => 'new_api_key', 'label' => AO::helper('adminhtml')->__('New Api Key'), 'id' => 'new_pass', 'title' => AO::helper('adminhtml')->__('New Api Key'), 'class' => 'input-text validate-password')); $fieldset->addField('confirmation', 'password', array('name' => 'api_key_confirmation', 'label' => AO::helper('adminhtml')->__('Api Key Confirmation'), 'id' => 'confirmation', 'class' => 'input-text validate-cpassword')); } else { $fieldset->addField('password', 'password', array('name' => 'api_key', 'label' => AO::helper('adminhtml')->__('Api Key'), 'id' => 'customer_pass', 'title' => AO::helper('adminhtml')->__('Api Key'), 'class' => 'input-text required-entry validate-password', 'required' => true)); $fieldset->addField('confirmation', 'password', array('name' => 'api_key_confirmation', 'label' => AO::helper('adminhtml')->__('Api Key Confirmation'), 'id' => 'confirmation', 'title' => AO::helper('adminhtml')->__('Api Key Confirmation'), 'class' => 'input-text required-entry validate-cpassword', 'required' => true)); } if (AO::getSingleton('admin/session')->getUser()->getId() != $model->getUserId()) { $fieldset->addField('is_active', 'select', array('name' => 'is_active', 'label' => AO::helper('adminhtml')->__('This account is'), 'id' => 'is_active', 'title' => AO::helper('adminhtml')->__('Account status'), 'class' => 'input-select', 'style' => 'width: 80px', 'options' => array('1' => AO::helper('adminhtml')->__('Active'), '0' => AO::helper('adminhtml')->__('Inactive')))); } $fieldset->addField('user_roles', 'hidden', array('name' => 'user_roles', 'id' => '_user_roles')); $data = $model->getData(); unset($data['password']); $form->setValues($data); $this->setForm($form); return parent::_prepareForm(); }
public function getAllOptions() { if (is_null($this->_options)) { $this->_options = AO::getResourceModel('core/store_collection')->load()->toOptionArray(); } return $this->_options; }
function getProduct() { if (!$this->_product) { $this->_product = AO::registry('product'); } return $this->_product; }
public function __construct() { $this->_controller = 'catalog_product_attribute'; $this->_headerText = AO::helper('catalog')->__('Manage Attributes'); $this->_addButtonLabel = AO::helper('catalog')->__('Add New Attribute'); parent::__construct(); }
/** * Return customer group collection * * @return Mage_Customer_Model_Entity_Group_Collection */ public function getCustomerGroups() { if (is_null($this->_customerGroups)) { $this->_customerGroups = AO::getModel('customer/group')->getCollection(); } return $this->_customerGroups; }
/** * Translate a phrase * * @return string */ public function __() { $args = func_get_args(); $expr = new Mage_Core_Model_Translate_Expr(array_shift($args), $this->_getRealModuleName()); array_unshift($args, $expr); return AO::app()->getTranslator()->translate($args); }
public function __construct() { $this->_controller = 'tag_tag'; $this->_headerText = AO::helper('tag')->__('All Tags'); $this->_addButtonLabel = AO::helper('tag')->__('Add New Tag'); parent::__construct(); }