本文整理汇总了PHP中Varien_Object::setData方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Object::setData方法的具体用法?PHP Varien_Object::setData怎么用?PHP Varien_Object::setData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Object
的用法示例。
在下文中一共展示了Varien_Object::setData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareForm
protected function _prepareForm()
{
$form = new Varien_Data_Form();
$dataObj = new Varien_Object(array('store_id' => '', 'store_name_in_store' => '', 'status_in_store' => '', 'description_in_store' => '', 'address_in_store' => '', 'city_in_store' => ''));
if (Mage::getSingleton('adminhtml/session')->getStoreData()) {
$data = Mage::getSingleton('adminhtml/session')->getStoreData();
Mage::getSingleton('adminhtml/session')->setStoreData(null);
} elseif (Mage::registry('store_data')) {
$data = Mage::registry('store_data')->getData();
}
if (isset($data)) {
$dataObj->addData($data);
}
if ($dataObj->getStoreId()) {
$warehouse = Mage::getResourceModel('inventoryplus/warehouse_collection')->addFieldToFilter('storepickup_id', $dataObj->getStoreId())->getFirstItem();
$dataObj->setData('warehouse_id', $warehouse->getId());
$dataObj->setData('curr_warehouse_id', $warehouse->getId());
}
$this->setForm($form);
$fieldset = $form->addFieldset('store_form', array('legend' => Mage::helper('storepickup')->__('Warehouse Information')));
$fieldset->addField('warehouse_id', 'select', array('label' => Mage::helper('storepickup')->__('Linked Warehouse'), 'name' => 'warehouse_id', 'values' => $this->getWarehouseOptions(), 'onchange' => 'imStorePickup.changeWarehouse(this);', 'note' => $this->__('If you choose a warehouse, this Store information will be imported from the warehouse after saved.')));
$fieldset->addField('curr_warehouse_id', 'hidden', array('name' => 'curr_warehouse_id'));
if (Mage::getSingleton('adminhtml/session')->getStoreData()) {
$form->setValues(Mage::getSingleton('adminhtml/session')->getStoreData());
Mage::getSingleton('adminhtml/session')->setStoreData(null);
} elseif (Mage::registry('store_data')) {
$form->setValues($dataObj->getData());
}
parent::_prepareForm();
}
示例2: _prepareArrayRow
/**
* Assign extra parameters to row
*
* @param Varien_Object $row
*/
protected function _prepareArrayRow(Varien_Object $row)
{
$row->setData('option_extra_attr_' . $this->_getTemplateRenderer()->calcOptionHash($row->getData('template')), 'selected="selected"');
$row->setData('option_extra_attr_' . $this->_getSendtypeRenderer()->calcOptionHash($row->getData('sendtype')), 'selected="selected"');
$row->setData('option_extra_attr_' . $this->_getDatafieldRenderer()->calcOptionHash($row->getData('datafield')), 'selected="selected"');
$row->setData('option_extra_attr_' . $this->_getFromadddressRenderer()->calcOptionHash($row->getData('fromaddress')), 'selected="selected"');
}
示例3: _prepareForm
protected function _prepareForm()
{
$form = new Varien_Data_Form();
$blockData = Mage::registry(AW_Autorelated_Adminhtml_ShoppingcartblockController::BLOCK_REGISTRY_KEY);
if (!$blockData instanceof Varien_Object) {
$blockData = new Varien_Object();
}
$fieldset = $form->addFieldset('general', array('legend' => $this->__('General')));
$fieldset->addField('name', 'text', array('name' => 'name', 'label' => $this->__('Name'), 'required' => true));
if ($blockData->getData('status') === null) {
$blockData->setData('status', 1);
}
$fieldset->addField('status', 'select', array('name' => 'status', 'label' => $this->__('Status'), 'required' => true, 'values' => Mage::getModel('awautorelated/source_status')->toOptionArray()));
if (!Mage::app()->isSingleStoreMode()) {
$fieldset->addField('store', 'multiselect', array('name' => 'store[]', 'label' => $this->__('Store View'), 'required' => true, 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true)));
} else {
$blockData->setStore(Mage::app()->getStore(true)->getId());
$fieldset->addField('store', 'hidden', array('name' => 'store[]'));
}
if ($blockData->getData('customer_groups') === null) {
$blockData->setData('customer_groups', array(Mage_Customer_Model_Group::CUST_GROUP_ALL));
}
$fieldset->addField('customer_groups', 'multiselect', array('name' => 'customer_groups[]', 'label' => $this->__('Customer groups'), 'title' => $this->__('Customer groups'), 'required' => true, 'values' => Mage::getModel('awautorelated/source_customer_groups')->toOptionArray()));
$fieldset->addField('priority', 'text', array('name' => 'priority', 'label' => $this->__('Priority'), 'title' => $this->__('Priority'), 'required' => false));
$dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
$fieldset->addField('date_from', 'date', array('name' => 'date_from', 'label' => $this->__('Date From'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'input_format' => Varien_Date::DATE_INTERNAL_FORMAT, 'format' => $dateFormatIso));
$fieldset->addField('date_to', 'date', array('name' => 'date_to', 'label' => $this->__('Date To'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'input_format' => Varien_Date::DATE_INTERNAL_FORMAT, 'format' => $dateFormatIso));
$positionSourceModel = Mage::getModel('awautorelated/source_position');
$fieldset->addField('position', 'select', array('name' => 'position', 'label' => $this->__('Position'), 'title' => $this->__('Position'), 'required' => true, 'values' => $positionSourceModel->toOptionArray(AW_Autorelated_Model_Source_Type::SHOPPING_CART_BLOCK)));
$form->setValues($blockData->toArray());
$this->setForm($form);
}
示例4: afterSave
/**
* After attribute is saved upload file to media
* folder and save it to its associated product.
*
* @param Mage_Catalog_Model_Product $object
* @return Jvs_FileAttribute_Model_Attribute_Backend_File
*/
public function afterSave($object)
{
$value = $object->getData($this->getAttribute()->getName());
if (is_array($value) && !empty($value['delete'])) {
$object->setData($this->getAttribute()->getName(), '');
$this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
return;
}
try {
$uploadedFile = new Varien_Object();
$uploadedFile->setData('name', $this->getAttribute()->getName());
$uploadedFile->setData('allowed_extensions', array('jpg', 'jpeg', 'gif', 'png', 'tif', 'tiff', 'mpg', 'mpeg', 'mp3', 'wav', 'pdf', 'txt'));
Mage::dispatchEvent('jvs_fileattribute_allowed_extensions', array('file' => $uploadedFile));
$uploader = new Mage_Core_Model_File_Uploader($this->getAttribute()->getName());
$uploader->setAllowedExtensions($uploadedFile->getData('allowed_extensions'));
$uploader->setAllowRenameFiles(true);
$uploader->setFilesDispersion(true);
$uploader->save(Mage::getBaseDir('media') . '/catalog/product');
} catch (Exception $e) {
return $this;
}
$fileName = $uploader->getUploadedFileName();
if ($fileName) {
$object->setData($this->getAttribute()->getName(), $fileName);
$this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
}
return $this;
}
示例5: beforeSave
/**
* Formating date value before save
*
* Should set (bool, string) correct type for empty value from html form,
* neccessary for farther proccess, else date string
*
* @param Varien_Object $object
* @throws Mage_Eav_Exception
* @return Mage_Eav_Model_Entity_Attribute_Backend_Datetime
*/
public function beforeSave($object)
{
$attributeName = $this->getAttribute()->getName();
$_formated = $object->getData($attributeName . '_is_formated');
if (!$_formated && $object->hasData($attributeName)) {
try {
if (Mage::app()->getLocale()->getLocale() == 'fa_IR') {
require_once Mage::getBaseDir('lib') . '/pdate/pdate.php';
if ($object->getData($attributeName) != NULL) {
list($j_y, $j_m, $j_d) = explode('/', $object->getData($attributeName));
$gregorianlArray = jalali_to_gregorian($j_y, $j_m, $j_d);
$date = implode('-', $gregorianlArray);
$object->setData($attributeName, $date);
}
}
$value = $this->formatDate($object->getData($attributeName));
} catch (Exception $e) {
throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('Invalid date'));
}
if (is_null($value)) {
$value = $object->getData($attributeName);
}
//Mage::log( "$attributeName, $value ") ;
$object->setData($attributeName, $value);
$object->setData($attributeName . '_is_formated', true);
}
return $this;
}
示例6: editAction
public function editAction()
{
$id = $this->getRequest()->getParam('id');
$shippingrate = new Varien_Object();
//Mage::getModel('shipping/carrier_tablerate');
if ($id) {
// Load record
$resource = Mage::getResourceModel('shipping/carrier_tablerate');
$adapter = Mage::getSingleton('core/resource')->getConnection('core_read');
$binds = array('id' => $id);
$query = "select * FROM {$resource->getMainTable()} WHERE `pk` = :id";
$data = $adapter->fetchRow($query, $binds);
// Check if record is loaded
if (!$data) {
Mage::getSingleton('adminhtml/session')->addError($this->__('This Shipping Rate no longer exists.'));
$this->_redirect('*/*/');
return;
} else {
$shippingrate->setData($data);
}
} else {
// for new rates set the default country to the country of the store
$shippingrate->setData('dest_country_id', Mage::getStoreConfig('general/country/default'));
$shippingrate->setData('website_id', Mage::app()->getRequest()->getParam('website'));
}
Mage::register('shippingrate', $shippingrate);
$this->_initAction();
$this->renderLayout();
}
示例7: _prepareArrayRow
protected function _prepareArrayRow(Varien_Object $row)
{
$row->setData('option_extra_attr_' . $this->getRenderer('attribute')->calcOptionHash($row->getAttribute()), 'selected="selected"');
$row->setData('option_extra_attr_' . $this->getRenderer('searchable')->calcOptionHash($row->getSearchable()), 'selected="selected"');
$row->setData('option_extra_attr_' . $this->getRenderer('searchable')->calcOptionHash($row->getRetrievable()), 'selected="selected"');
$row->setData('option_extra_attr_' . $this->getRenderer('order')->calcOptionHash($row->getOrder()), 'selected="selected"');
}
示例8: getJsonConfig
public function getJsonConfig(){
$_secure = false;
$sheme = Mage::app()->getRequest()->getScheme();
if ($sheme=='https'){
$_secure = true;
}
$merchantId = Mage::getStoreConfig('payment/incontext/merchantid');
$isActive = Mage::getStoreConfig('payment/incontext/enable');
$environment = 'production';
if (Mage::getStoreConfig('payment/incontext/sandbox')){
$environment = 'sandbox';
}
if (empty($merchantId)){
$isActive = false;
}
$config = new Varien_Object();
$config->setData('isActive', $isActive);
$config->setData('environment', $environment);
$config->setData('merchantid', $merchantId);
$config->setData('setExpressCheckout', $this->getUrl('incontext/express/start', array('_secure' => $_secure)));
$config->setData('setExpressCheckoutUk', $this->getUrl('incontext/expressuk/start', array('_secure' => $_secure)));
return Mage::helper('core')->jsonEncode($config);
}
示例9: authorize
/**
* Authorize payment method
*
* @param Varien_Object $payment
* @param float $amount
*
* @throws Exception Payment could not be executed
*
* @return Iways_PayPalPlus_Model_Payment
*/
public function authorize(Varien_Object $payment, $amount)
{
$paymentId = Mage::app()->getRequest()->getParam('paymentId');
$payerId = Mage::app()->getRequest()->getParam('PayerID');
try {
if (Mage::getStoreConfig('payment/iways_paypalplus_payment/transfer_reserved_order_id')) {
Mage::getModel('iways_paypalplus/api')->patchInvoiceNumber($paymentId, $payment->getOrder()->getIncrementId());
}
} catch (\Exception $e) {
Mage::logException($e);
}
/**
* @var \PayPal\Api\Payment $ppPayment
*/
$ppPayment = Mage::getModel('iways_paypalplus/api')->executePayment($paymentId, $payerId);
Mage::getSingleton('customer/session')->setPayPalPaymentId(null);
Mage::getSingleton('customer/session')->setPayPalPaymentPatched(null);
if (!$ppPayment) {
Mage::throwException('Payment could not be executed.');
}
if ($paymentInstructions = $ppPayment->getPaymentInstruction()) {
$payment->setData('ppp_pui_reference_number', $paymentInstructions->getReferenceNumber());
$payment->setData('ppp_pui_instruction_type', $paymentInstructions->getInstructionType());
$payment->setData('ppp_pui_payment_due_date', Mage::helper('iways_paypalplus')->convertDueDate($paymentInstructions->getPaymentDueDate()));
$payment->setData('ppp_pui_note', $paymentInstructions->getNote());
$bankInsctructions = $paymentInstructions->getRecipientBankingInstruction();
$payment->setData('ppp_pui_bank_name', $bankInsctructions->getBankName());
$payment->setData('ppp_pui_account_holder_name', $bankInsctructions->getAccountHolderName());
$payment->setData('ppp_pui_international_bank_account_number', $bankInsctructions->getInternationalBankAccountNumber());
$payment->setData('ppp_pui_bank_identifier_code', $bankInsctructions->getBankIdentifierCode());
$payment->setData('ppp_pui_routing_number', $bankInsctructions->getRoutingNumber());
$ppAmount = $paymentInstructions->getAmount();
$payment->setData('ppp_pui_amount', $ppAmount->getValue());
$payment->setData('ppp_pui_currency', $ppAmount->getCurrency());
}
$transactionId = null;
try {
$transactions = $ppPayment->getTransactions();
if ($transactions && isset($transactions[0])) {
$resource = $transactions[0]->getRelatedResources();
if ($resource && isset($resource[0])) {
$sale = $resource[0]->getSale();
$transactionId = $sale->getId();
if ($sale->getState() == self::PENDING) {
$payment->setIsTransactionPending(true);
}
}
}
} catch (Exception $e) {
$transactionId = $ppPayment->getId();
}
$payment->setTransactionId($transactionId);
$payment->setParentTransactionId($ppPayment->getId());
if ($ppPayment->getState() == self::PPP_STATUS_APPROVED) {
$payment->setStatus(self::STATUS_APPROVED);
}
return $this;
}
示例10: _prepareArrayRow
protected function _prepareArrayRow(Varien_Object $row)
{
$date_from = $row->getData('date_from') ? Mage::helper('core')->formatDate($row->getData('date_from'), Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, false) : "";
$date_end = $row->getData('date_end') ? Mage::helper('core')->formatDate($row->getData('date_end'), Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, false) : "";
$row->setData('date_from', $date_from);
$row->setData('date_end', $date_end);
$row->setData('option_extra_attr_' . $this->_getCalculationTypeReferrerRenderer()->calcOptionHash($row->getData('calculation_type_referrer')), 'selected="selected"');
$row->setData('option_extra_attr_' . $this->_getCalculationTypeReferredRenderer()->calcOptionHash($row->getData('calculation_type_referred')), 'selected="selected"');
}
示例11: _processPeriod
private function _processPeriod($collection, $period)
{
switch ($period) {
case 'day':
return $collection;
break;
case 'month':
$index = 1;
break;
case 'year':
$index = 0;
break;
}
$fields = array('abandoned_carts_num', 'abandoned_carts_price', 'abandoned_items_num', 'recovered_carts_num', 'ordered_carts_num', 'ordered_carts_price', 'ordered_items_num', 'av_back_time', 'target_letter_step');
$date = $collection->getFirstItem()->getDate();
$dateArray = explode('-', $date);
$val = $dateArray[$index];
$returnCollection = new Varien_Data_Collection();
$object = new Varien_Object();
//$counterABT=0;
$counterTLS = 0;
foreach ($collection as $item) {
$dateArray = explode('-', $item->getDate());
if ($dateArray[$index] != $val) {
$val = $dateArray[$index];
/*if($counterABT)
{
$object->setData('av_back_time',$object->getData('av_back_time')/$counterABT);
}*/
if ($counterTLS) {
$object->setData('target_letter_step', $object->getData('target_letter_step') / $counterTLS);
}
$returnCollection->addItem($object);
$object = new Varien_Object();
$counterABT = 0;
$counterTLS = 0;
}
$object->setDate($item->getDate());
//if($item->getData('av_back_time'))$counterABT++;
if ($item->getData('target_letter_step')) {
$counterTLS++;
}
foreach ($fields as $field) {
$object->setData($field, $object->getData($field) + $item->getData($field));
}
}
/*if($counterABT)
{
$object->setData('av_back_time',$object->getData('av_back_time')/$counterABT);
}*/
if ($counterTLS) {
$object->setData('target_letter_step', $object->getData('target_letter_step') / $counterTLS);
}
$returnCollection->addItem($object);
return $returnCollection;
}
示例12: sendReportEmail
public function sendReportEmail()
{
$websites = Mage::app()->getWebsites(true);
$helper = Mage::helper('affiliateplus/config');
foreach ($websites as $website) {
if (!$website->getConfig('affiliateplus/email/is_sent_report')) {
continue;
}
$periodData = array('week' => array('date' => 'w', 'label' => $helper->__('last week')), 'month' => array('date' => 'j', 'label' => $helper->__('last month')), 'year' => array('date' => 'z', 'label' => $helper->__('last year')));
$period = $website->getConfig('affiliateplus/email/report_period');
if (date($periodData[$period]['date']) != 1) {
continue;
}
$store = $website->getDefaultStore();
if (!$store) {
continue;
}
$storeId = $store->getId();
$accounts = Mage::getResourceModel('affiliateplus/account_collection')->addFieldToFilter('main_table.status', 1)->addFieldToFilter('main_table.notification', 1);
$accounts->getSelect()->joinLeft(array('e' => $accounts->getTable('customer/entity')), 'main_table.customer_id = e.entity_id', array('website_id'))->where('e.website_id = ?', $website->getId())->where('e.is_active = 1');
//edit by Sally
$date = new Zend_Date();
$to = $date->toString();
//$to = Mage::helper('core')->formatDate($date,'medium', true);
$to = Mage::getModel('core/locale')->storeDate(Mage::app()->getStore(), $to, true)->toString('dd-MM-YYYY HH:mm:ss');
$function = 'sub' . ucfirst($period);
$fromDate = $date->{$function}(1)->toString('YYYY-MM-dd');
$from = $date->toString();
// $from = Mage::helper('core')->formatDate($date,'medium', true);
$from = Mage::getModel('core/locale')->storeDate(Mage::app()->getStore(), $from, true)->toString('dd-MM-YYYY HH:mm:ss');
//end by Sally
$translate = Mage::getSingleton('core/translate');
$translate->setTranslateInline(false);
$template = $website->getConfig('affiliateplus/email/report_template');
$sender = Mage::getStoreConfig('trans_email/ident_sales', $store);
foreach ($accounts as $account) {
$statistic = new Varien_Object();
$transactions = Mage::getResourceModel('affiliateplus/transaction_collection')->addFieldToFilter('account_id', $account->getId());
$transactions->getSelect()->reset(Zend_Db_Select::COLUMNS)->where('date(created_time) >= ?', $fromDate)->columns(array('status', 'sales' => 'SUM(`total_amount`)', 'transactions' => 'COUNT(`transaction_id`)', 'commissions' => 'SUM(`commission`+`commission`*`percent_plus`+`commission_plus`)'))->group('status');
foreach ($transactions as $transaction) {
if ($transaction->getStatus() == 1) {
$statistic->setData('complete', $transaction->getData());
} elseif ($transaction->getStatus() == 2) {
$statistic->setData('pending', $transaction->getData());
} elseif ($transaction->getStatus() == 3) {
$statistic->setData('cancel', $transaction->getData());
}
}
$actions = Mage::getResourceModel('affiliateplus/action_collection');
$actions->getSelect()->reset(Zend_Db_Select::COLUMNS)->where('account_id = ?', $account->getId())->where('type = ?', 2)->where('created_date >= ?', $fromDate)->columns(array('clicks' => 'SUM(totals)', 'unique' => 'SUM(is_unique)'))->group('account_id');
$statistic->setData('click', $actions->getFirstItem()->getData());
$mailTemplate = Mage::getModel('core/email_template')->setDesignConfig(array('area' => 'frontend', 'store' => $storeId))->sendTransactional($template, $sender, $account->getEmail(), $account->getName(), array('store' => $store, 'account' => $account, 'statistic' => $statistic, 'period' => $helper->__($period), 'label' => $periodData[$period]['label'], 'from' => $from, 'to' => $to));
}
$translate->setTranslateInline(true);
}
}
示例13: getConfig
public function getConfig($data = array())
{
$config = new Varien_Object();
$config->setData(array('enabled' => $this->isEnabled(), 'hidden' => $this->isHidden(), 'use_container' => false, 'add_variables' => false, 'add_widgets' => false, 'no_display' => false, 'translator' => Mage::helper('cms'), 'files_browser_window_url' => Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/cms_wysiwyg_images/index'), 'files_browser_window_width' => (int) Mage::getConfig()->getNode('adminhtml/cms/browser/window_width'), 'files_browser_window_height' => (int) Mage::getConfig()->getNode('adminhtml/cms/browser/window_height'), 'encode_directives' => true, 'directives_url' => Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/cms_wysiwyg/directive'), 'popup_css' => Mage::getBaseUrl('js') . 'mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/dialog.css', 'content_css' => Mage::getBaseUrl('js') . 'mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/content.css', 'width' => '100%', 'plugins' => array()));
$config->setData('directives_url_quoted', preg_quote($config->getData('directives_url')));
if (is_array($data)) {
$config->addData($data);
}
return $config;
}
示例14: _beforeSave
/**
* Also serialize additional information
*
* @param Varien_Object $payment
*/
protected function _beforeSave(Varien_Object $payment)
{
$additionalInformation = $payment->getData('additional_information');
if (empty($additionalInformation)) {
$payment->setData('additional_information', null);
} elseif (is_array($additionalInformation)) {
$payment->setData('additional_information', serialize($additionalInformation));
}
parent::_beforeSave($payment);
}
示例15: setParams
/**
* Sets the parameter array
*
* @param array $params
*/
public function setParams($params)
{
if ($params instanceof Varien_Object) {
$this->_params = $params;
}
else {
$this->_params->setData($params);
}
return $this;
}