本文整理汇总了PHP中Varien_Object::setType方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Object::setType方法的具体用法?PHP Varien_Object::setType怎么用?PHP Varien_Object::setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Object
的用法示例。
在下文中一共展示了Varien_Object::setType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetTokenInfo
public function testGetTokenInfo()
{
$payment = new Varien_Object();
$payment->setCcCid('789');
$vaultCard = new Varien_Object();
$vaultCard->setCcType('VI');
$vaultCard->setLast4('1234');
$vaultCard->setType('VI');
$vaultCard->setExpirationMonth('12');
$vaultCard->setExpirationYear('2050');
$vaultCard->setToken('1111222233331234');
$litle = new Litle_CreditCard_Model_PaymentLogic();
$modelPalorusVault = $this->getMock('Litle_Palorus_Model_Vault');
$modelPalorusVault->expects($this->any())->method('load')->with($this->equalTo(50))->will($this->returnValue($vaultCard));
$litle->setModelPalorusVault($modelPalorusVault);
$info = new Mage_Payment_Model_Info();
$info->setAdditionalInformation('cc_vaulted', 50);
$arr = array('info_instance' => $info);
$litle->addData($arr);
$tokenInfo = $litle->getTokenInfo($payment);
$this->assertEquals('1234', $payment->getCcLast4());
$this->assertEquals('VI', $payment->getCcType());
$this->assertEquals('789', $tokenInfo['cardValidationNum']);
$this->assertEquals('VI', $tokenInfo['type']);
$this->assertEquals('1111222233331234', $tokenInfo['litleToken']);
$this->assertEquals('1250', $tokenInfo['expDate']);
}
示例2: _loadXmlElementCustomParams
protected function _loadXmlElementCustomParams($element)
{
$params = array();
$sortOrder = 0;
foreach ($element->asCanonicalArray() as $key => $data) {
if (is_array($data)) {
$data['sort_order'] = isset($data['sort_order']) ? (int) $data['sort_order'] : 'top';
// Prepare values (for dropdowns) specified directly in configuration
$values = array();
if (isset($data['values']) && is_array($data['values'])) {
foreach ($data['values'] as $value) {
if (isset($value['label']) && isset($value['value'])) {
$values[] = $value;
}
}
}
$data['values'] = $values;
// Prepare helper block object
if (isset($data['helper_block'])) {
$helper = new Varien_Object();
if (isset($data['helper_block']['data']) && is_array($data['helper_block']['data'])) {
$helper->addData($data['helper_block']['data']);
}
if (isset($data['helper_block']['type'])) {
$helper->setType($data['helper_block']['type']);
}
$data['helper_block'] = $helper;
}
$params[$key] = $data;
$sortOrder++;
}
}
return $params;
}
示例3: _prepareForm
protected function _prepareForm()
{
$form = new Varien_Data_Form();
if (Mage::registry('gomage_feed')) {
$item = Mage::registry('gomage_feed');
} else {
$item = new Varien_Object();
}
$this->setForm($form);
$fieldset = $form->addFieldset('main_fieldset', array('legend' => $this->__('Item information')));
$headerBar = $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array('label' => Mage::helper('catalog')->__('Feed Pro Help'), 'class' => 'go', 'id' => 'feed_pro_help', 'onclick' => 'window.open(\'http://www.gomage.com/faq/extensions/feed-pro\')'));
$fieldset->setHeaderBar($headerBar->toHtml());
$fieldset->addField('type', 'hidden', array('name' => 'type'));
$fieldset->addField('name', 'text', array('name' => 'name', 'label' => $this->__('Name'), 'title' => $this->__('Name'), 'required' => true, 'note' => $this->__('e.g. "Google Base", "Yahoo! Store"...')));
if ($item->getId() && ($url = $item->getUrl())) {
$fieldset->addField('comments', 'note', array('label' => $this->__('Access Url'), 'title' => $this->__('Access Url'), 'text' => '<a href="' . $url . '" target="_blank">' . $url . '</a>'));
}
$fieldset->addField('filename', 'text', array('name' => 'filename', 'label' => $this->__('Filename'), 'title' => $this->__('Filename'), 'required' => false, 'note' => $this->__('e.g. "productfeed.csv", "productfeed.xml"...')));
$fieldset->addField('store_id', 'select', array('label' => $this->__('Store View'), 'required' => true, 'name' => 'store_id', 'values' => Mage::getModel('gomage_feed/adminhtml_system_config_source_store')->getStoreValuesForForm()));
if (!$item->getType() && $this->getRequest()->getParam('type')) {
$item->setType($this->getRequest()->getParam('type'));
}
$form->setValues($item->getData());
return parent::_prepareForm();
}
示例4: getPaymentType
/**
* Return the PayPal payment type
*
* @return mixed
*/
public function getPaymentType()
{
$object = new Varien_Object();
$object->setType($this->_getConfig('payment_type'));
// Specific event for this method
Mage::dispatchEvent('gene_paypal_get_payment_type', array('object' => $object));
return $object->getType();
}
示例5: _createReport
/**
* Creates a new report.
*
* @return Varien_Object
*/
protected function _createReport()
{
$report = new Varien_Object();
$report->setType($this->_getType());
$report->setEntityType($this->_getEntity());
$report->setFailures(0);
$report->setSuccesses(0);
$report->setDuplicates(0);
return $report;
}
示例6: _getRewritesArray
protected function _getRewritesArray()
{
$rewritesArray = array();
foreach ($this->getTypes() as $type => $label) {
$rewrites = $this->_collectRewrites($type);
foreach ($rewrites as $initialClass => $rewritesData) {
$rewriteItem = new Varien_Object();
$rewriteItem->setClass($initialClass);
$rewriteItem->setType($type);
$rewriteItem->setRewrites($rewritesData);
$rewriteItem->setConflict($this->_getConflict($rewritesData['classes']));
$rewritesArray[] = $rewriteItem;
}
}
return $rewritesArray;
}
示例7: getAsyncCollection
public function getAsyncCollection()
{
$this->getSavedTime();
$result = array();
$processes = Mage::getSingleton('index/indexer')->getProcessesCollection();
$eventsCollection = Mage::getResourceModel('index/event_collection');
$eventsCollection->addProcessFilter($processes->getAllIds(), Mage_Index_Model_Process::EVENT_STATUS_NEW);
$eventsCollection->getSelect()->group('entity')->group('entity_pk');
$this->setQueueSize($eventsCollection->count());
foreach ($eventsCollection as $event) {
$item = new Varien_Object();
$item->setType($event->getType());
$item->setEntity($event->getEntity());
$item->setEntityPk($event->getEntityPk());
$result[] = $item;
if (count($result) > 10) {
break;
}
}
return $result;
}
示例8: _prepareForm
protected function _prepareForm()
{
$form = new Varien_Data_Form();
if (Mage::registry('ranvi_feed')) {
$item = Mage::registry('ranvi_feed');
} else {
$item = new Varien_Object();
}
$this->setForm($form);
$fieldset = $form->addFieldset('main_fieldset', array('legend' => $this->__('Item information')));
$fieldset->addField('type', 'hidden', array('name' => 'type'));
$fieldset->addField('name', 'text', array('name' => 'name', 'label' => $this->__('Name'), 'title' => $this->__('Name'), 'required' => true));
if ($item->getId() && ($url = $item->getUrl())) {
$fieldset->addField('comments', 'note', array('label' => $this->__('Access Url'), 'title' => $this->__('Access Url'), 'text' => '<a href="' . $url . '" target="_blank">' . $url . '</a>'));
}
$fieldset->addField('filename', 'text', array('name' => 'filename', 'label' => $this->__('Filename'), 'title' => $this->__('Filename'), 'required' => false));
$fieldset->addField('store_id', 'select', array('label' => $this->__('Store View'), 'required' => true, 'name' => 'store_id', 'values' => Mage::getModel('ranvi_feed/adminhtml_system_config_source_store')->getStoreValuesForForm()));
if (!$item->getType() && $this->getRequest()->getParam('type')) {
$item->setType($this->getRequest()->getParam('type'));
}
$form->setValues($item->getData());
return parent::_prepareForm();
}
示例9: _prepareForm
protected function _prepareForm()
{
$form = new Varien_Data_Form();
if (Mage::registry('gomage_custom_attribute')) {
$item = Mage::registry('gomage_custom_attribute');
} else {
$item = new Varien_Object();
}
$this->setForm($form);
$fieldset = $form->addFieldset('main_fieldset', array('legend' => $this->__('Attribute Information')));
$fieldset->addField('type', 'hidden', array('name' => 'type'));
$headerBar = $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array('label' => Mage::helper('catalog')->__('Feed Pro Help'), 'class' => 'go', 'id' => 'feed_pro_help', 'onclick' => 'window.open(\'http://www.gomage.com/faq/extensions/feed-pro\')'));
$fieldset->setHeaderBar($headerBar->toHtml());
$fieldset->addField('code', 'text', array('name' => 'code', 'label' => $this->__('Dynamic Attribute Code'), 'title' => $this->__('Dynamic Attribute Code'), 'required' => true, 'class' => 'validate-code', 'note' => $this->__('For internal use. Must be unique with no spaces')));
$fieldset->addField('name', 'text', array('name' => 'name', 'label' => $this->__('Name'), 'title' => $this->__('Name'), 'required' => true, 'note' => $this->__('e.g. "Custom Price", "Google Category"...')));
if (!$item->getType() && $this->getRequest()->getParam('type')) {
$item->setType($this->getRequest()->getParam('type'));
}
if ($item->getId()) {
$form->setValues($item->getData());
}
return parent::_prepareForm();
}
示例10: promptAction
/**
* Submit prompt action
*
* @return string
*/
public function promptAction()
{
$params = $this->getRequest()->getParams();
$response = new Varien_Object();
try {
$key = $params['id'];
$data = $params['data'];
if (empty($key) || empty($data)) {
Mage::throwException('Parameters key and data are required');
}
if (!($prompt = $this->_loadPrompt($key))) {
Mage::throwException('Session time out, try again');
}
$request = $this->_getRequestModel()->setRequest($prompt)->dispatch($data);
$response->setStatus('OK');
$response->setMessage($request->getMessage());
$response->setType(MageHack_MageConsole_Model_Abstract::RESPONSE_TYPE_MESSAGE);
} catch (Exception $e) {
$response->setStatus('ERROR');
$response->setType(MageHack_MageConsole_Model_Abstract::RESPONSE_TYPE_ERROR);
$response->setMessage($e->getMessage());
}
$this->getResponse()->setHeader('Content-Type', 'application/json', true)->setBody($response->toJson());
}
示例11: getItemTypes
/**
* Returns Google Base recommended Item Types
*
* @param string $targetCountry Two-letters country ISO code
* @return array
*/
public function getItemTypes($targetCountry)
{
$locale = Mage::getSingleton('googlebase/config')->getCountryInfo($targetCountry, 'locale');
$location = self::ITEM_TYPES_LOCATION . '/' . $locale;
$itemTypes = array();
foreach ($this->getGuestService()->getFeed($location)->entries as $entry) {
if (isset($entry->extensionElements[1])) {
// has attributes node?
$typeAttributes = $entry->extensionElements[1]->extensionElements;
if (is_array($typeAttributes) && !empty($typeAttributes)) {
// only items with attributes allowed
$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;
$attributes = array();
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;
}
示例12: getConfigAsObject
/**
* Return widget XML configuration as Varien_Object and makes some data preparations
*
* @param string $type Widget type
* @return Varien_Object
*/
public function getConfigAsObject($type)
{
$xml = $this->getConfigAsXml($type);
$object = new Varien_Object();
if ($xml === null) {
return $object;
}
// Save all nodes to object data
$object->setType($type);
$object->setData($xml->asCanonicalArray());
// Set module for translations etc.
$module = $object->getData('@/module');
if ($module) {
$object->setModule($module);
}
// Correct widget parameters and convert its data to objects
$params = $object->getData('parameters');
$newParams = array();
if (is_array($params)) {
$sortOrder = 0;
foreach ($params as $key => $data) {
if (is_array($data)) {
$data['key'] = $key;
$data['sort_order'] = isset($data['sort_order']) ? (int) $data['sort_order'] : $sortOrder;
// prepare values (for drop-dawns) specified directly in configuration
$values = array();
if (isset($data['values']) && is_array($data['values'])) {
foreach ($data['values'] as $value) {
if (isset($value['label']) && isset($value['value'])) {
$values[] = $value;
}
}
}
$data['values'] = $values;
// prepare helper block object
if (isset($data['helper_block'])) {
$helper = new Varien_Object();
if (isset($data['helper_block']['data']) && is_array($data['helper_block']['data'])) {
$helper->addData($data['helper_block']['data']);
}
if (isset($data['helper_block']['type'])) {
$helper->setType($data['helper_block']['type']);
}
$data['helper_block'] = $helper;
}
$newParams[$key] = new Varien_Object($data);
$sortOrder++;
}
}
}
uasort($newParams, array($this, '_sortParameters'));
$object->setData('parameters', $newParams);
return $object;
}
示例13: getConfigAsObject
public function getConfigAsObject($code)
{
$xml = $this->getConfigAsXml($code);
$object = new Varien_Object();
if ($xml === null) {
return $object;
}
// Save all nodes to object data
$object->setCode($code);
$object->setData($xml->asCanonicalArray());
// Set module for translations etc..
$module = $object->getData('@/module');
$object->setModule($module ? $module : 'customgrid');
// Set type
$type = $object->getData('@/type');
$object->setType($type);
// Translate name, description and help
$helper = Mage::helper($object->getModule());
if ($object->hasName()) {
$object->setName($helper->__((string) $object->getName()));
}
if ($object->hasDescription()) {
$object->setDescription($helper->__((string) $object->getDescription()));
}
if ($object->hasHelp()) {
$object->setHelp($helper->__((string) $object->getHelp()));
}
if ($this->_acceptParameters) {
// Correct element parameters and convert its data to objects if needed
$params = $object->getData('parameters');
$newParams = array();
if (is_array($params)) {
$sortOrder = 0;
foreach ($params as $key => $data) {
if (is_array($data)) {
$data['key'] = $key;
$data['sort_order'] = isset($data['sort_order']) ? (int) $data['sort_order'] : $sortOrder;
// Prepare values (for dropdowns) specified directly in configuration
$values = array();
if (isset($data['values']) && is_array($data['values'])) {
foreach ($data['values'] as $value) {
if (isset($value['label']) && isset($value['value'])) {
$values[] = $value;
}
}
}
$data['values'] = $values;
// Prepare helper block object
if (isset($data['helper_block'])) {
$helper = new Varien_Object();
if (isset($data['helper_block']['data']) && is_array($data['helper_block']['data'])) {
$helper->addData($data['helper_block']['data']);
}
if (isset($data['helper_block']['type'])) {
$helper->setType($data['helper_block']['type']);
}
$data['helper_block'] = $helper;
}
$newParams[$key] = new Varien_Object($data);
$sortOrder++;
}
}
}
uasort($newParams, array($this, '_sortParameters'));
$object->setData('parameters', $newParams);
}
return $object;
}
示例14: getOptionValues
public function getOptionValues()
{
$data = array();
$optionsArr = '';
$data = $this->getTemplateData();
if (isset($data['hash_options'])) {
$optionsArr = $data['hash_options'];
}
$zendDate = new Zend_Date();
$dateFormat = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
$helper = Mage::helper('customoptions');
$helper->getCustomerGroups();
// init customer_groups for sort prices
$groupId = (int) $this->getRequest()->getParam('group_id');
if ($optionsArr) {
$optionsArr = unserialize($optionsArr);
}
$store = Mage::app()->getStore($this->getStoreId());
$storeOptionsArr = array();
$groupStore = Mage::getSingleton('customoptions/group_store')->loadByGroupAndStore($groupId, $this->getStoreId());
if ($groupStore->getHashOptions()) {
$storeOptionsArr = unserialize($groupStore->getHashOptions());
}
//print_r($storeOptionsArr); exit;
$optionModel = Mage::getSingleton('catalog/product_option');
if (!$this->_values && $optionsArr) {
$values = array();
$sortOrder = array();
$scope = (int) Mage::app()->getStore()->getConfig(Mage_Core_Model_Store::XML_PATH_PRICE_SCOPE);
$optionItemCount = count($optionsArr);
foreach ($optionsArr as $optionId => $option) {
$option = new Varien_Object($option);
$value = array();
if ($option->getIsDelete() != '1') {
$value['id'] = $option->getOptionId();
$value['item_count'] = $optionItemCount;
$value['option_id'] = $option->getOptionId();
$value['title'] = $this->htmlEscape(isset($storeOptionsArr[$optionId]['title']) ? $storeOptionsArr[$optionId]['title'] : $option->getTitle());
// old view_mode = hidden => to new type = 'hidden';
if ($optionModel->getGroupByType($option->getType()) == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT && $option->getViewMode() == 2) {
$option->setType('hidden');
$option->setViewMode(1);
}
$value['type'] = $option->getType();
$value['is_require'] = $option->getIsRequire();
$value['view_mode'] = isset($storeOptionsArr[$optionId]['view_mode']) ? $storeOptionsArr[$optionId]['view_mode'] : $option->getViewMode();
$value['is_dependent'] = $option->getIsDependent();
$value['div_class'] = $option->getDivClass();
$value['sku_policy'] = $option->getSkuPolicy();
$value['customoptions_is_onetime'] = $option->getCustomoptionsIsOnetime();
$value['qnty_input'] = $option->getQntyInput() ? 'checked' : '';
$value['qnty_input_disabled'] = $option->getType() == 'multiple' || $option->getType() == 'hidden' ? 'disabled' : '';
$value['image_mode'] = $option->getImageMode();
$value['image_mode_disabled'] = $optionModel->getGroupByType($option->getType()) != Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT ? 'disabled' : '';
$value['exclude_first_image'] = $option->getExcludeFirstImage() ? 'checked' : '';
$value['description'] = $this->htmlEscape(isset($storeOptionsArr[$optionId]['description']) ? $storeOptionsArr[$optionId]['description'] : $option->getDescription());
if ($helper->isCustomerGroupsEnabled() && $option->getCustomerGroups() != null) {
$value['customer_groups'] = implode(',', $option->getCustomerGroups());
}
if ($helper->isStoreViewsEnabled() && $option->getStoreViews() != null) {
$value['store_views'] = implode(',', $option->getStoreViews());
}
$value['in_group_id'] = $option->getInGroupId();
$value['in_group_id_view'] = $option->getInGroupId();
$value['sort_order'] = $this->_getSortOrder($option);
if ($this->getStoreId() != '0') {
$value['checkboxScopeTitle'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'title', !isset($storeOptionsArr[$optionId]['title']));
$value['scopeTitleDisabled'] = !isset($storeOptionsArr[$optionId]['title']) ? 'disabled' : null;
$value['checkboxScopeViewMode'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'view_mode', !isset($storeOptionsArr[$optionId]['view_mode']));
$value['scopeViewModeDisabled'] = !isset($storeOptionsArr[$optionId]['view_mode']) ? 'disabled' : null;
$value['checkboxScopeDescription'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'description', !isset($storeOptionsArr[$optionId]['description']));
$value['scopeDescriptionDisabled'] = !isset($storeOptionsArr[$optionId]['description']) ? 'disabled' : null;
}
if ($optionModel->getGroupByType($option->getType()) == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT) {
$countValues = count($option->getValues());
if ($countValues > 0) {
foreach ($option->getValues() as $key => $_value) {
$_value = new Varien_Object($_value);
$_value->setOptionTypeId($key);
if ($_value->getIsDelete() != '1') {
$defaultArray = $option->getDefault() !== null ? $option->getDefault() : array();
if (isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price'])) {
$_value->setPrice(floatval($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price']));
}
if (isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price_type'])) {
$_value->setPriceType($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price_type']);
}
// for support old format:
if (isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['special_price'])) {
$_value->setSpecialPrice(floatval($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['special_price']));
}
if (isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['special_comment'])) {
$_value->setSpecialComment($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['special_comment']);
}
if ($_value->getSpecialPrice()) {
$_value->setSpecials(array(array('customer_group_id' => 32000, 'price' => $_value->getSpecialPrice(), 'price_type' => 'fixed', 'comment' => $_value->getSpecialComment(), 'date_from' => '', 'date_to' => '')));
}
$helper->applyLinkedBySkuDataToOption($_value, $_value->getSku(), $store, 0);
$helper->calculateOptionSpecialPrice($_value, null, $helper->isSpecialPriceEnabled());
$priceDisabled = $_value->getIsSkuPrice();
//.........这里部分代码省略.........
示例15: addCallbackFilter
/**
* Add filter with a callback
*
* @param string $field field to filter
* @param string $value value
* @param string $type and|or
* @param string $callback callback method
*
* @return Smile_MageCache_Model_Action_Collection
*/
public function addCallbackFilter($field, $value, $type = 'and', $callback = 'filterCallbackEqual')
{
$filter = new Varien_Object();
$filter->setField($field);
$filter->setValue($value);
$filter->setType(strtolower($type));
$filter->setCallback($callback);
$this->_filters[] = $filter;
$this->_isFiltersRendered = false;
return $this;
}