本文整理汇总了PHP中Mage::getResourceModel方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage::getResourceModel方法的具体用法?PHP Mage::getResourceModel怎么用?PHP Mage::getResourceModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage
的用法示例。
在下文中一共展示了Mage::getResourceModel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareCollection
protected function _prepareCollection()
{
$collection = Mage::getResourceModel('reports/tag_product_collection');
$collection->addUniqueTagedCount()->addAllTagedCount()->addStatusFilter(Mage::getModel('tag/tag')->getApprovedStatus())->addGroupByProduct();
$this->setCollection($collection);
return parent::_prepareCollection();
}
示例2: _getCollectionForRetrieve
/**
* Retrieve collection instances
*
* @return Mage_Sales_Model_Resource_Order_Status_History_Collection
*/
protected function _getCollectionForRetrieve()
{
/* @var $collection Mage_Sales_Model_Resource_Order_Status_History_Collection */
$collection = Mage::getResourceModel('Mage_Sales_Model_Resource_Order_Status_History_Collection');
$collection->setOrderFilter($this->_loadOrderById($this->getRequest()->getParam(self::PARAM_ORDER_ID)));
return $collection;
}
示例3: handleEventBlockAlert
public function handleEventBlockAlert($observer)
{
$product = Mage::registry('current_product');
if ('product.info.addtocart' == $observer->getEvent()->getBlock()->getNameInLayout() && $product->getTypeId() == 'virtual') {
$today = date("Y-m-d");
$mainCollection = Mage::getResourceModel('wage_trainevent/trainevent_collection')->addStoreFilter(Mage::app()->getStore())->addProductFilter($product);
$firstCollection = $mainCollection->getFirstItem();
$trainEventEndDate = $firstCollection->getData('end_date');
if (strtotime($today) >= strtotime($trainEventEndDate) && $trainEventEndDate) {
$isLogged = Mage::helper('customer')->isLoggedIn();
if (!$isLogged) {
$transport = $observer->getEvent()->getTransport();
$alertBlock = Mage::app()->getLayout()->createBlock('wage_trainevent/trainevent_subscribe', 'event.subscribe');
$alertBlock->setTemplate('wage_trainevent/subscribe_guest.phtml');
$html = $alertBlock->toHtml();
$transport->setHtml($html);
} else {
$transport = $observer->getEvent()->getTransport();
$alertBlock = Mage::app()->getLayout()->createBlock('wage_trainevent/trainevent_subscribe', 'event.subscribe');
$alertBlock->setTemplate('wage_trainevent/subscribe_customer.phtml');
$alertBlock->setHtmlClass('alert-stock link-stock-alert');
$alertBlock->setSignupLabel('Sign up to get notified to get next Event Planning');
$html = $alertBlock->toHtml();
$transport->setHtml($html);
}
}
}
}
示例4: _prepareCollection
protected function _prepareCollection()
{
$collection = Mage::getResourceModel('googlebase/type_collection')->addItemsCount();
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
}
示例5: save
public function save()
{
foreach ($this->getData() as $i => $row) {
$this->setExceptionLocation('Line: ' . $i);
$entity = Mage::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(Mage::helper('Mage_Eav_Helper_Data')->__('An error occurred while loading a record, aborting. Error: %s', $e->getMessage()), Varien_Convert_Exception::FATAL);
}
if (!$entity->getId()) {
$this->addException(Mage::helper('Mage_Eav_Helper_Data')->__('Invalid entity_id, skipping the record.'), Varien_Convert_Exception::ERROR);
continue;
}
}
try {
$entity->addData($row)->save();
} catch (Exception $e) {
$this->addException(Mage::helper('Mage_Eav_Helper_Data')->__('An error occurred while saving a record, aborting. Error: ', $e->getMessage()), Varien_Convert_Exception::FATAL);
}
}
return $this;
}
示例6: getBillingAgreements
/**
* Retrieve billing agreements collection
*
* @return Mage_Sales_Model_Mysql4_Billing_Agreement_Collection
*/
public function getBillingAgreements()
{
if (is_null($this->_billingAgreements)) {
$this->_billingAgreements = Mage::getResourceModel('sales/billing_agreement_collection')->addFieldToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomerId())->setOrder('agreement_id', 'desc');
}
return $this->_billingAgreements;
}
示例7: _renderCellTemplate
protected function _renderCellTemplate($columnName)
{
$inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
if ($columnName == "template") {
$collection = Mage::getResourceModel('core/email_template_collection')->load();
$arr_select = $collection->toOptionArray();
array_unshift($arr_select, array('label' => Mage::helper('rewardpoints')->__('Default'), 'value' => ''));
return $this->_getTemplateRenderer()->setName($inputName)->setTitle($columnName)->setExtraParams('style="width:260px"')->setOptions($arr_select)->toHtml();
} else {
if ($columnName == "sender") {
$arr_select = array();
$config = Mage::getSingleton('adminhtml/config')->getSection('trans_email')->groups->children();
foreach ($config as $node) {
$nodeName = $node->getName();
$label = (string) $node->label;
$sortOrder = (int) $node->sort_order;
$arr_select[$sortOrder] = array('value' => preg_replace('#^ident_(.*)$#', '$1', $nodeName), 'label' => Mage::helper('adminhtml')->__($label));
}
ksort($arr_select);
/*array_unshift(
$arr_select,
array(
'label' => Mage::helper('rewardpoints')->__('Default'),
'value' => ''
)
);*/
return $this->_getSenderRenderer()->setName($inputName)->setTitle($columnName)->setExtraParams('style="width:260px"')->setOptions($arr_select)->toHtml();
}
}
return parent::_renderCellTemplate($columnName);
}
示例8: _prepareForm
protected function _prepareForm()
{
$collection = Mage::getResourceModel('clmcenter/comment_collection');
$mcenter_id = $this->getRequest()->getParam('id');
$tableName = Mage::getSingleton('core/resource')->getTableName('clmcenter_mcenter');
$collection->getSelect()->joinLeft($tableName, 'main_table.mcenter_id = ' . $tableName . '.mcenter_id', 'title');
$collection->getSelect()->distinct();
$collection->getSelect()->where('main_table.mcenter_id =' . $mcenter_id);
$collection->getSelect()->limit(1);
$data = $collection->getData();
$form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))), 'method' => 'post'));
$fieldset = $form->addFieldset('comment_form', array('legend' => Mage::helper('clmcenter')->__('Комментарий')));
$fieldset->addField('title', 'hidden', array('label' => Mage::helper('clmcenter')->__('Наименование'), 'after_element_html' => '<tr><td class="label"><label for="title">Наименование</label></td>
<td class="value">' . $data[0]['title'] . '</td></tr>'));
$fieldset->addField('user', 'text', array('label' => Mage::helper('clmcenter')->__('Пользователь'), 'name' => 'user'));
$fieldset->addField('email', 'text', array('label' => Mage::helper('clmcenter')->__('E-mail'), 'name' => 'email'));
$fieldset->addField('comment_status', 'select', array('label' => Mage::helper('clmcenter')->__('Статус'), 'name' => 'comment_status', 'values' => array(array('value' => CommerceLab_Mcenter_Helper_Data::UNAPPROVED_STATUS, 'label' => Mage::helper('clmcenter')->__('Отклонен')), array('value' => CommerceLab_Mcenter_Helper_Data::APPROVED_STATUS, 'label' => Mage::helper('clmcenter')->__('Одобрен')))));
$fieldset->addField('comment', 'editor', array('name' => 'comment', 'label' => Mage::helper('clmcenter')->__('Комментарий'), 'title' => Mage::helper('clmcenter')->__('Комментарий'), 'style' => 'width:500px; height:250px;', 'wysiwyg' => false, 'required' => false));
if (Mage::getSingleton('adminhtml/session')->getMcenterData()) {
$form->setValues(Mage::getSingleton('adminhtml/session')->getMcenterData());
Mage::getSingleton('adminhtml/session')->setMcenterData(null);
} elseif (Mage::registry('clmcenter_data')) {
$form->setValues(Mage::registry('clmcenter_data')->getData());
}
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
示例9: _getCollectionForRetrieve
/**
* Retrieve collection instances
*
* @return Mage_Sales_Model_Resource_Order_Address_Collection
*/
protected function _getCollectionForRetrieve()
{
/* @var $collection Mage_Sales_Model_Resource_Order_Address_Collection */
$collection = Mage::getResourceModel('sales/order_address_collection');
$collection->addAttributeToFilter('parent_id', $this->getRequest()->getParam(self::PARAM_ORDER_ID));
return $collection;
}
示例10: getOptionText
public function getOptionText($value)
{
if (!$value) {
$value = '0';
}
$isMultiple = false;
if (strpos($value, ',')) {
$isMultiple = true;
$value = explode(',', $value);
}
if (!$this->_options) {
$collection = Mage::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' => Mage::helper('customer')->__('Admin')));
}
}
if ($isMultiple) {
$values = array();
foreach ($value as $val) {
$values[] = $this->_options[$val];
}
return $values;
} else {
return $this->_options[$value];
}
return false;
}
示例11: _prepareCollection
/**
* Get collection from commission table
*
* Return array of data to with seller commission information
*
* @return array
*/
protected function _prepareCollection()
{
$gid = Mage::helper('marketplace')->getGroupId();
$collection = Mage::getResourceModel('customer/customer_collection')->addNameToSelect()->addAttributeToSelect('email')->addAttributeToSelect('created_at')->addAttributeToSelect('group_id')->addFieldToFilter('group_id', $gid);
$this->setCollection($collection);
return parent::_prepareCollection();
}
示例12: getAllOptions
public function getAllOptions()
{
if (!$this->_options) {
$this->_options = Mage::getResourceModel('tax/class_collection')->addFieldToFilter('class_type', 'CUSTOMER')->load()->toOptionArray();
}
return $this->_options;
}
示例13: _prepareLayout
protected function _prepareLayout()
{
if (!Mage::helper('core')->isModuleEnabled('Mage_Reports')) {
return $this;
}
$isFilter = $this->getRequest()->getParam('store') || $this->getRequest()->getParam('website') || $this->getRequest()->getParam('group');
$collection = Mage::getResourceModel('reports/order_collection')->calculateSales($isFilter);
if ($this->getRequest()->getParam('store')) {
$collection->addFieldToFilter('store_id', $this->getRequest()->getParam('store'));
} else {
if ($this->getRequest()->getParam('website')) {
$storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
$collection->addFieldToFilter('store_id', array('in' => $storeIds));
} else {
if ($this->getRequest()->getParam('group')) {
$storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
$collection->addFieldToFilter('store_id', array('in' => $storeIds));
}
}
}
$collection->load();
$sales = $collection->getFirstItem();
$this->addTotal($this->__('Lifetime Sales'), $sales->getLifetime());
$this->addTotal($this->__('Average Orders'), $sales->getAverage());
}
示例14: isTypeAllowed
/**
* Check is block with such type allowed for parsinf via blockDirective method
*
* @param $type
* @return int
*/
public function isTypeAllowed($type)
{
/** @var Mage_Admin_Model_Resource_Block_Collection $collection */
$collection = Mage::getResourceModel('admin/block_collection');
$collection->addFieldToFilter('block_name', array('eq' => $type))->addFieldToFilter('is_allowed', array('eq' => 1));
return $collection->load()->count();
}
示例15: __construct
public function __construct()
{
parent::__construct();
//TODO: add full name logic
$orders = Mage::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', Mage::getSingleton('customer/session')->getCustomer()->getId())->addAttributeToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))->addAttributeToSort('created_at', 'desc')->setPageSize('5')->load();
$this->setOrders($orders);
}