本文整理汇总了PHP中Varien_Object::setDescription方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Object::setDescription方法的具体用法?PHP Varien_Object::setDescription怎么用?PHP Varien_Object::setDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Object
的用法示例。
在下文中一共展示了Varien_Object::setDescription方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLastNotice
public function getLastNotice()
{
if ($this->showExtendwarePopup === false) {
return parent::getLastNotice();
}
static $lastNotice = false;
if ($lastNotice === false) {
$lastNotice = null;
$message = Mage::helper('ewcore/notification')->getMessage();
if ($message) {
$lastNotice = new Varien_Object();
$lastNotice->setTitle($message->getSubject());
$lastNotice->setDescription($message->getSummary());
$lastNotice->setUrl($this->getUrl('extendware_ewcore/adminhtml_message/edit', array('id' => $message->getId())));
$lastNotice->setSeverity(Mage_AdminNotification_Model_Inbox::SEVERITY_MINOR);
switch ($message->getSeverity()) {
case 'notice':
$lastNotice->setSeverity(Mage_AdminNotification_Model_Inbox::SEVERITY_NOTICE);
break;
case 'minor':
$lastNotice->setSeverity(Mage_AdminNotification_Model_Inbox::SEVERITY_MINOR);
break;
case 'major':
$lastNotice->setSeverity(Mage_AdminNotification_Model_Inbox::SEVERITY_MAJOR);
break;
case 'critical':
$lastNotice->setSeverity(Mage_AdminNotification_Model_Inbox::SEVERITY_CRITICAL);
break;
}
}
}
return $lastNotice;
}
示例2: _prepareCollection
/**
* Prepare grid collection
*/
protected function _prepareCollection()
{
$collection = new Varien_Data_Collection();
$layout = $this->getLayout();
$update = $layout->getUpdate();
$design = Mage::getSingleton('core/design_package');
$layoutXML = $update->getFileLayoutUpdatesXml('frontend', $design->getPackageName(), $design->getTheme('layout'), 0);
$xpath = $layoutXML->xpath('//action[@method="setEsi"]');
foreach ($xpath as $x) {
$esi = new Varien_Object();
$handle = $x->xpath('ancestor::node()[last()-2]');
$handleName = $handle[0]->label ? $handle[0]->label : $handle[0]->getName();
$parentBlock = $x->xpath('parent::*');
$parentBlockName = $parentBlock[0]->getAttribute('name');
$parentBlockDescription = $parentBlock[0]->getAttribute('description');
$cacheType = $x->params->cache_type ? $x->params->cache_type : "global";
$esi->setId($parentBlockName);
$esi->setHandle($handleName);
$esi->setBlockName($parentBlockName);
$esi->setDescription($parentBlockDescription);
$esi->setCacheType($cacheType);
try {
$collection->addItem($esi);
} catch (Exception $e) {
Mage::logException($e);
}
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
示例3: saveAction
public function saveAction()
{
$data = new Varien_Object($this->getRequest()->getParam('payment', array()));
$data->setCustomerId(Mage::helper('iugu')->getCustomerId());
$data->setDescription(Mage::getModel('core/date')->timestamp(time()));
$result = Mage::getSingleton('iugu/api')->savePaymentMethod($data);
if ($result->getErrors()) {
Mage::getSingleton('customer/session')->addError($this->__('An error occurred while saving the credit card.'));
} else {
Mage::getSingleton('customer/session')->addSuccess(Mage::helper('iugu')->__('Credit card has been saved.'));
}
$this->_redirect('*/*/');
}
示例4: _place
protected function _place($payment, $amount)
{
$order = $payment->getOrder();
$payer = Mage::helper('iugu')->getPayerInfoFromOrder($payment->getOrder());
$items = Mage::helper('iugu')->getItemsFromOrder($payment->getOrder());
// Verify if needs add interest
$interestRate = $this->getInterestRate($payment->getInstallments());
$totalWithInterest = $this->calcTotalWithInterest($amount, $interestRate);
if ($totalWithInterest - $amount > 0) {
$item = new Varien_Object();
$item->setDescription(Mage::helper('iugu')->__('Interest'));
$item->setQuantity(1);
$item->setPriceCents(Mage::helper('iugu')->formatAmount($totalWithInterest - $amount));
$items[] = $item;
}
// Save Payment method
if (!$payment->getIuguCustomerPaymentMethodId() && $payment->getIuguSave()) {
$data = new Varien_Object();
$data->setToken($payment->getIuguToken());
$data->setCustomerId(Mage::helper('iugu')->getCustomerId());
$data->setDescription(Mage::getModel('core/date')->timestamp(time()));
$result = Mage::getSingleton('iugu/api')->savePaymentMethod($data);
if ($result->getId()) {
$payment->setIuguCustomerPaymentMethodId($result->getId());
}
}
// Set Charge Data
$data = new Varien_Object();
if ($payment->getIuguCustomerPaymentMethodId()) {
$data->setCustomerPaymentMethodId($payment->getIuguCustomerPaymentMethodId());
} else {
$data->setToken($payment->getIuguToken());
}
$data->setMonths($payment->getInstallments())->setEmail($order->getCustomerEmail())->setItems($items)->setPayer($payer);
// Discount
if ($order->getBaseDiscountAmount()) {
$data->setDiscountCents(Mage::helper('iugu')->formatAmount(abs($order->getBaseDiscountAmount())));
}
// Tax
if ($order->getBaseTaxAmount()) {
$data->setTaxCents($this->formatAmount($order->getBaseTaxAmount()));
}
// Charge
$result = Mage::getSingleton('iugu/api')->charge($data);
if (!$result->getSuccess()) {
Mage::throwException(Mage::helper('iugu')->__('Transaction failed, please try again or contact the card issuing bank.'));
}
// Set iugu info
$payment->setIuguInvoiceId($result->getInvoiceId())->setIuguTotalWithInterest($totalWithInterest)->setIuguUrl($result->getUrl())->setIuguPdf($result->getPdf())->setTransactionId($result->getInvoiceId())->setIsTransactionClosed(0)->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, array('message' => $result->getMessage()));
return $this;
}
示例5: _getActions
/**
* Retrieve actions collection
*
* @return array
* @throws Exception
*/
protected function _getActions()
{
$config = Mage::getSingleton('smile_magecache/config');
$actionsConfig = $config->getActionConfig();
$items = array();
$i = 0;
foreach ($actionsConfig as $code => $actionConfig) {
$action = new Varien_Object();
$action->setPosition($i++);
$action->setCode($actionConfig->getCode());
$action->setName($actionConfig->getModel()->getLabel());
$action->setDescription($actionConfig->getModel()->getDescription());
$items[] = $action;
}
return $items;
}
示例6: getItemsFromOrder
public function getItemsFromOrder($order)
{
$items = array();
foreach ($order->getAllVisibleItems() as $data) {
$item = new Varien_Object();
$item->setDescription($data->getName());
$item->setQuantity($data->getQtyOrdered());
$item->setPriceCents($this->formatAmount($data->getBasePrice()));
$items[] = $item;
}
// Shipping
if ($order->getBaseShippingAmount() > 0) {
$item = new Varien_Object();
$item->setDescription($this->__('Shipping & Handling') . ' (' . $order->getShippingDescription() . ')');
$item->setQuantity(1);
$item->setPriceCents($this->formatAmount($order->getBaseShippingAmount()));
$items[] = $item;
}
return $items;
}
示例7: _prepareCollection
/**
* Prepare collection of errors
*
* @return Enterprise_Checkout_Block_Adminhtml_Sku_Errors_Grid
*/
protected function _prepareCollection()
{
$collection = new Varien_Data_Collection();
$removeButtonHtml = $this->getLayout()->createBlock('adminhtml/widget_button', '', array('class' => 'delete', 'label' => '', 'onclick' => 'addBySku.removeFailedItem(this)', 'type' => 'button'))->toHtml();
/* @var $parentBlock Enterprise_Checkout_Block_Adminhtml_Sku_Errors_Abstract */
$parentBlock = $this->getParentBlock();
foreach ($parentBlock->getFailedItems() as $affectedItem) {
// Escape user-submitted input
if (isset($affectedItem['item']['qty'])) {
$affectedItem['item']['qty'] = empty($affectedItem['item']['qty']) ? '' : (double) $affectedItem['item']['qty'];
}
$item = new Varien_Object();
$item->setCode($affectedItem['code']);
if (isset($affectedItem['error'])) {
$item->setError($affectedItem['error']);
}
$item->addData($affectedItem['item']);
$item->setId($item->getSku());
/* @var $product Mage_Catalog_Model_Product */
$product = Mage::getModel('catalog/product');
if (isset($affectedItem['item']['id'])) {
$productId = $affectedItem['item']['id'];
$item->setProductId($productId);
$product->load($productId);
/* @var $stockStatus Mage_CatalogInventory_Model_Stock_Status */
$stockStatus = Mage::getModel('cataloginventory/stock_status');
$status = $stockStatus->getProductStatus($productId, $this->getWebsiteId());
if (!empty($status[$productId])) {
$product->setIsSalable($status[$productId]);
}
$item->setPrice(Mage::helper('core')->formatPrice($product->getPrice()));
}
$descriptionBlock = $this->getLayout()->createBlock('enterprise_checkout/adminhtml_sku_errors_grid_description', '', array('product' => $product, 'item' => $item));
$item->setDescription($descriptionBlock->toHtml());
$item->setRemoveButton($removeButtonHtml);
$collection->addItem($item);
}
$this->setCollection($collection);
return $this;
}
示例8: _applyPostPageLogic
protected function _applyPostPageLogic($object, $type = 'post')
{
$meta = new Varien_Object(array('title' => $this->_getTitleFormat($type)));
if (($value = trim($object->getMetaValue('_aioseop_title'))) !== '') {
$data = $this->getRewriteData();
$data[$type . '_title'] = $value;
$this->setRewriteData($data);
}
if (($value = trim($object->getMetaValue('_aioseop_description'))) !== '') {
$meta->setDescription($value);
}
if (($value = trim($object->getMetaValue('_aioseop_keywords'))) !== '') {
$meta->setKeywords($value);
}
if ($type === 'post') {
$keywords = rtrim($meta->getKeywords(), ',') . ',';
if ($this->getUseCategories()) {
foreach ($object->getParentCategories() as $category) {
$keywords .= $category->getName() . ',';
}
}
if ($this->getUseTagsAsKeywords()) {
foreach ($object->getTags() as $tag) {
$keywords .= $tag->getName() . ',';
}
}
$meta->setKeywords(trim($keywords, ','));
}
$this->_applyMeta($meta->getData());
return $this;
}
示例9: 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;
}
示例10: _applyPostPageLogic
protected function _applyPostPageLogic($object, $type = 'post')
{
$meta = new Varien_Object(array('title' => $this->_getTitleFormat($type), 'description' => trim($this->getData('metadesc_' . $type)), 'keywords' => trim($this->getData('metakey_' . $type))));
if (($value = trim($object->getMetaValue('_yoast_wpseo_title'))) !== '') {
$data = $this->getRewriteData();
$data['title'] = $value;
$this->setRewriteData($data);
}
if (($value = trim($object->getMetaValue('_yoast_wpseo_metadesc'))) !== '') {
$meta->setDescription($value);
}
$robots = array();
$noIndex = (int) $object->getMetaValue('_yoast_wpseo_meta-robots-noindex');
if ($noIndex === 0) {
$robots['noindex'] = '';
} else {
if ($noIndex === 1) {
$robots['noindex'] = '';
} else {
if ($noIndex === 2) {
$robots['index'] = '';
} else {
if ($this->getNoindexPost()) {
$robots['noindex'] = '';
}
}
}
}
if ($object->getMetaValue('_yoast_wpseo_meta-robots-nofollow')) {
$robots['nofollow'] = '';
} else {
$robots['follow'] = '';
}
if (($advancedRobots = trim($object->getMetaValue('_yoast_wpseo_meta-robots-adv'))) !== '') {
if ($advancedRobots !== 'none') {
$robots = explode(',', $advancedRobots);
}
}
$robots = array_keys($robots);
if (count($robots) > 0) {
$meta->setRobots(implode(',', $robots));
}
$this->_applyMeta($meta->getData());
if (($headBlock = $this->_getHeadBlock()) !== false) {
if ($canon = $object->getMetaValue('_yoast_wpseo_canonical')) {
$headBlock->removeItem('link_rel', $object->getUrl());
$headBlock->addItem('link_rel', $canon, 'rel="canonical"');
}
$this->_addGooglePlusLinkRel($object->getAuthor());
}
return $this;
}
示例11: _applyPostPageLogic
/**
* Process the SEO values for the blog view page
*
* @param Varien_Object $object
* @param string $type
* @param Varien_Object $page
*/
protected function _applyPostPageLogic($object, $type = 'post')
{
$meta = new Varien_Object(array('title' => $this->_getTitleFormat($type), 'description' => trim($this->getData('metadesc_' . $type)), 'keywords' => trim($this->getData('metakey_' . $type))));
if (($value = trim($object->getMetaValue('_yoast_wpseo_title'))) !== '') {
$data = $this->getRewriteData();
$data['title'] = $value;
$this->setRewriteData($data);
}
if (($value = trim($object->getMetaValue('_yoast_wpseo_metadesc'))) !== '') {
$meta->setDescription($value);
}
if (($value = trim($object->getMetaValue('_yoast_wpseo_metakeywords'))) !== '') {
$meta->setKeywords($value);
}
$robots = array();
$noIndex = (int) $object->getMetaValue('_yoast_wpseo_meta-robots-noindex');
if ($noIndex === 0) {
$robots['index'] = '';
} else {
if ($noIndex === 1) {
$robots['noindex'] = '';
} else {
if ($noIndex === 2) {
$robots['index'] = '';
} else {
if ($this->getNoindexPost()) {
$robots['noindex'] = '';
}
}
}
}
if ($object->getMetaValue('_yoast_wpseo_meta-robots-nofollow')) {
$robots['nofollow'] = '';
} else {
$robots['follow'] = '';
}
if (($advancedRobots = trim($object->getMetaValue('_yoast_wpseo_meta-robots-adv'))) !== '') {
if ($advancedRobots !== 'none') {
$robots = explode(',', $advancedRobots);
}
}
$robots = array_keys($robots);
if (count($robots) > 0) {
$meta->setRobots(implode(',', $robots));
}
$this->_applyMeta($meta->getData());
if ($canon = $object->getMetaValue('_yoast_wpseo_canonical')) {
$object->setCanonicalUrl($canon);
}
if (!$this->hasOpengraph() || (int) $this->getOpengraph() === 1) {
$this->_addPostOpenGraphTags($object, $type);
}
if ($this->getTwitter()) {
$this->_addTwitterCard(array('card' => $this->getTwitterCardType(), 'site' => $this->getTwitterSite() ? '@' . $this->getTwitterSite() : '', 'title' => $object->getPostTitle(), 'creator' => ($creator = $object->getAuthor()->getMetaValue('twitter')) ? '@' . $creator : ''));
}
return $this;
}
示例12: getCurrentSeo
//.........这里部分代码省略.........
$seo = Mage::getSingleton('seo/object_product');
} elseif ($isCategory && $isFilter) {
$seo = Mage::getSingleton('seo/object_filter');
} elseif ($isCategory) {
$seo = Mage::getSingleton('seo/object_category');
} else {
$seo = new Varien_Object();
}
if ($seoTempalate = $this->checkTempalateRule($isProduct, $isCategory, $isFilter)) {
foreach ($seoTempalate->getData() as $k => $v) {
if ($v) {
$seo->setData($k, $v);
}
}
}
if ($seoRewrite = $this->checkRewrite()) {
foreach ($seoRewrite->getData() as $k => $v) {
if ($v) {
$seo->setData($k, $v);
}
}
}
$storeId = Mage::app()->getStore()->getStoreId();
$page = Mage::app()->getFrontController()->getRequest()->getParam('p');
if (!$page) {
$page = 1;
}
if ($isCategory && !$isProduct) {
if ($this->_titlePage) {
switch ($this->_config->getMetaTitlePageNumber($storeId)) {
case Mirasvit_Seo_Model_Config::META_TITLE_PAGE_NUMBER_BEGIN:
if ($page > 1) {
$seo->setMetaTitle(Mage::helper('seo')->__("Page %s | %s", $page, $seo->getMetaTitle()));
$this->_titlePage = false;
}
break;
case Mirasvit_Seo_Model_Config::META_TITLE_PAGE_NUMBER_END:
if ($page > 1) {
$seo->setMetaTitle(Mage::helper('seo')->__("%s | Page %s", $seo->getMetaTitle(), $page));
$this->_titlePage = false;
}
break;
case Mirasvit_Seo_Model_Config::META_TITLE_PAGE_NUMBER_BEGIN_FIRST_PAGE:
$seo->setMetaTitle(Mage::helper('seo')->__("Page %s | %s", $page, $seo->getMetaTitle()));
$this->_titlePage = false;
break;
case Mirasvit_Seo_Model_Config::META_TITLE_PAGE_NUMBER_END_FIRST_PAGE:
$seo->setMetaTitle(Mage::helper('seo')->__("%s | Page %s", $seo->getMetaTitle(), $page));
$this->_titlePage = false;
break;
}
}
if ($this->_descriptionPage) {
switch ($this->_config->getMetaDescriptionPageNumber($storeId)) {
case Mirasvit_Seo_Model_Config::META_DESCRIPTION_PAGE_NUMBER_BEGIN:
if ($page > 1) {
$seo->setMetaDescription(Mage::helper('seo')->__("Page %s | %s", $page, $seo->getMetaDescription()));
$this->_descriptionPage = false;
}
break;
case Mirasvit_Seo_Model_Config::META_DESCRIPTION_PAGE_NUMBER_END:
if ($page > 1) {
$seo->setMetaDescription(Mage::helper('seo')->__("%s | Page %s", $seo->getMetaDescription(), $page));
$this->_descriptionPage = false;
}
break;
case Mirasvit_Seo_Model_Config::META_DESCRIPTION_PAGE_NUMBER_BEGIN_FIRST_PAGE:
$seo->setMetaDescription(Mage::helper('seo')->__("Page %s | %s", $page, $seo->getMetaDescription()));
$this->_descriptionPage = false;
break;
case Mirasvit_Seo_Model_Config::META_DESCRIPTION_PAGE_NUMBER_END_FIRST_PAGE:
$seo->setMetaDescription(Mage::helper('seo')->__("%s | Page %s", $seo->getMetaDescription(), $page));
$this->_descriptionPage = false;
break;
}
}
if ($page > 1) {
$seo->setDescription('');
//set an empty description for page with number > 1 (to not have a duplicate content)
}
}
if ($metaTitleMaxLength = $this->_config->getMetaTitleMaxLength($storeId)) {
$metaTitleMaxLength = (int) $metaTitleMaxLength;
if ($metaTitleMaxLength < Mirasvit_Seo_Model_Config::META_TITLE_INCORRECT_LENGTH) {
$metaTitleMaxLength = Mirasvit_Seo_Model_Config::META_TITLE_MAX_LENGTH;
//recommended length
}
$seo->setMetaTitle($this->_getTruncatedString($seo->getMetaTitle(), $metaTitleMaxLength, $page));
}
if ($metaDescriptionMaxLength = $this->_config->getMetaDescriptionMaxLength($storeId)) {
$metaDescriptionMaxLength = (int) $metaDescriptionMaxLength;
if ($metaDescriptionMaxLength < Mirasvit_Seo_Model_Config::META_DESCRIPTION_INCORRECT_LENGTH) {
$metaDescriptionMaxLength = Mirasvit_Seo_Model_Config::META_DESCRIPTION_MAX_LENGTH;
//recommended length
}
$seo->setMetaDescription($this->_getTruncatedString($seo->getMetaDescription(), $metaDescriptionMaxLength, $page));
}
Mage::helper('mstcore/debug')->end($uid, $seo->getData());
return $seo;
}
示例13: _mapTranscationDetails
/**
* Convert xml object to a Varien object.
*
* @param SimpleXMLElement $xml Xml response from the API.
* @return object Api response into a Varien object.
*/
private function _mapTranscationDetails(SimpleXMLElement $xml)
{
$object = new Varien_Object();
$object->setErrorcode($xml->errorcode);
$object->setTimestamp($xml->timestamp);
if ((string) $xml->errorcode === '0000') {
$object->setVpstxid($xml->vpstxid);
$object->setContactNumber($xml->contactnumber);
$object->setVendortxcode($xml->vendortxcode);
$object->setTransactiontype($xml->transactiontype);
$object->setStatus($xml->status);
$object->setDescription($xml->description);
$object->setAmount($xml->amount);
$object->setCurrency($xml->currency);
$object->setStarted($xml->started);
$object->setCompleted($xml->completed);
$object->setSecuritykey($xml->securitykey);
$object->setClientip($xml->clientip);
$object->setIplocation($xml->iplocation);
$object->setGiftaid($xml->giftaid);
$object->setPaymentsystem($xml->paymentsystem);
$object->setPaymentsystemdetails($xml->paymentsystemdetails);
$object->setAuthprocessor($xml->authprocessor);
$object->setMerchantnumber($xml->merchantnumber);
$object->setAccounttype($xml->accounttype);
$object->setBillingaddress($xml->billingaddress);
$object->setBillingpostcode($xml->billingpostcode);
$object->setDeliveryaddress($xml->deliveryaddress);
$object->setDeliverypostcode($xml->deliverypostcode);
$object->setSystemused($xml->systemused);
$object->setCustomeremail($xml->customeremail);
$object->setAborted($xml->aborted);
$object->setRefunded($xml->refunded);
$object->setRepeated($xml->repeated);
$object->setBasket($xml->basket);
$object->setApplyavscv2($xml->applyavscv2);
$object->setApply3dsecure($xml->apply3dsecure);
$object->setAttempt($xml->attempt);
$object->setCardholder($xml->cardholder);
$object->setCardaddress($xml->cardaddress);
$object->setCardpostcode($xml->cardpostcode);
$object->setStartdate($xml->startdate);
$object->setExpirydate($xml->expirydate);
$object->setLast4digits($xml->last4digits);
$object->setThreedresult($xml->threedresult);
$object->setEci($xml->eci);
$object->setCavv($xml->cavv);
$object->setT3mscore($xml->t3mscore);
$object->setT3maction($xml->t3maction);
$object->setT3mid($xml->t3mid);
} else {
$object->setError(htmlentities($xml->error));
}
return $object;
}
示例14: _getGeneralTrnData
/**
* Return commno data for *all* transactions.
* @return array Data
*/
public function _getGeneralTrnData(Varien_Object $payment)
{
$order = $payment->getOrder();
$quoteObj = $this->_getQuote();
$vendorTxCode = $this->_getTrnVendorTxCode();
if ($payment->getCcNumber()) {
$vendorTxCode .= $this->_cleanString(substr($payment->getCcOwner(), 0, 10));
}
$payment->setVendorTxCode($vendorTxCode);
$request = new Varien_Object();
$request->setVPSProtocol('2.23')->setReferrerID($this->getConfigData('referrer_id'))->setVendor($this->getConfigData('vendor'))->setVendorTxCode($vendorTxCode);
$request->setClientIPAddress($this->getClientIp());
if ($payment->getIntegra()) {
$this->getSageSuiteSession()->setLastVendorTxCode($vendorTxCode);
$request->setIntegration($payment->getIntegra());
$request->setData('notification_URL', $this->getNotificationUrl() . '&vtxc=' . $vendorTxCode);
$request->setData('success_URL', $this->getSuccessUrl());
$request->setData('redirect_URL', $this->getRedirectUrl());
$request->setData('failure_URL', $this->getFailureUrl());
}
if ($this->_getIsAdminOrder()) {
$request->setAccountType('M');
}
if ($payment->getAmountOrdered()) {
$from = $order->getOrderCurrencyCode();
if ((string) $this->getConfigData('trncurrency') == 'store') {
$request->setAmount($this->formatAmount($quoteObj->getGrandTotal(), $quoteObj->getQuoteCurrencyCode()));
$request->setCurrency($quoteObj->getQuoteCurrencyCode());
} else {
$request->setAmount($this->formatAmount($quoteObj->getBaseGrandTotal(), $quoteObj->getBaseCurrencyCode()));
$request->setCurrency($quoteObj->getBaseCurrencyCode());
}
}
if (!empty($order)) {
$billing = $order->getBillingAddress();
if (!empty($billing)) {
$request->setBillingAddress($billing->getStreet(1) . ' ' . $billing->getCity() . ' ' . $billing->getRegion() . ' ' . $billing->getCountry())->setBillingSurname($this->ss($billing->getLastname(), 20))->setBillingFirstnames($this->ss($billing->getFirstname(), 20))->setBillingPostCode($this->ss($billing->getPostcode(), 10))->setBillingAddress1($this->ss($billing->getStreet(1), 100))->setBillingAddress2($this->ss($billing->getStreet(2), 100))->setBillingCity($this->ss($billing->getCity(), 40))->setBillingCountry($billing->getCountry())->setContactNumber(substr($this->_cphone($billing->getTelephone()), 0, 20));
if ($billing->getCountry() == 'US') {
$request->setBillingState($billing->getRegionCode());
}
$request->setCustomerEMail($billing->getEmail());
}
if (!$request->getDescription()) {
$request->setDescription('.');
}
$shipping = $order->getShippingAddress();
if (!empty($shipping)) {
$request->setDeliveryAddress($shipping->getStreet(1) . ' ' . $shipping->getCity() . ' ' . $shipping->getRegion() . ' ' . $shipping->getCountry())->setDeliverySurname($this->ss($shipping->getLastname(), 20))->setDeliveryFirstnames($this->ss($shipping->getFirstname(), 20))->setDeliveryPostCode($this->ss($shipping->getPostcode(), 10))->setDeliveryAddress1($this->ss($shipping->getStreet(1), 100))->setDeliveryAddress2($this->ss($shipping->getStreet(2), 100))->setDeliveryCity($this->ss($shipping->getCity(), 40))->setDeliveryCountry($shipping->getCountry())->setDeliveryPhone($this->ss(urlencode($this->_cphone($shipping->getTelephone())), 20));
if ($shipping->getCountry() == 'US') {
$request->setDeliveryState($shipping->getRegionCode());
}
} else {
#If the cart only has virtual products, I need to put an shipping address to Sage Pay.
#Then the billing address will be the shipping address to
$request->setDeliveryAddress($billing->getStreet(1) . ' ' . $billing->getCity() . ' ' . $billing->getRegion() . ' ' . $billing->getCountry())->setDeliverySurname($this->ss($billing->getLastname(), 20))->setDeliveryFirstnames($this->ss($billing->getFirstname(), 20))->setDeliveryPostCode($this->ss($billing->getPostcode(), 10))->setDeliveryAddress1($this->ss($billing->getStreet(1), 100))->setDeliveryAddress2($this->ss($billing->getStreet(2), 100))->setDeliveryCity($this->ss($billing->getCity(), 40))->setDeliveryCountry($billing->getCountry())->setDeliveryPhone($this->ss(urlencode($this->_cphone($billing->getTelephone())), 20));
if ($billing->getCountry() == 'US') {
$request->setDeliveryState($billing->getRegionCode());
}
}
}
if ($payment->getCcNumber()) {
$request->setCardNumber($payment->getCcNumber())->setExpiryDate(sprintf('%02d%02d', $payment->getCcExpMonth(), substr($payment->getCcExpYear(), strlen($payment->getCcExpYear()) - 2)))->setCardType($payment->getCcType())->setCV2($payment->getCcCid())->setCardHolder($payment->getCcOwner());
if ($payment->getCcIssue()) {
$request->setIssueNumber($payment->getCcIssue());
}
if ($payment->getCcStartMonth() && $payment->getCcStartYear()) {
$request->setStartDate(sprintf('%02d%02d', $payment->getCcStartMonth(), substr($payment->getCcStartYear(), strlen($payment->getCcStartYear()) - 2)));
}
}
$totals = $shipping->getTotals();
$shippingTotal = isset($totals['shipping']) ? $totals['shipping']->getValue() : 0;
if ($this->getSendBasket()) {
$request->setBasket($this->_getBasketContents($quoteObj));
}
if (!$request->getDeliveryPostCode()) {
$request->setDeliveryPostCode('000');
}
if (!$request->getBillingPostCode()) {
$request->setBillingPostCode('000');
}
return $request;
}
示例15: writeTempFile
//.........这里部分代码省略.........
}
}
if ($option['value_type'] == 'percent') {
$value = floatval($attribute_value) / 100 * floatval($option['value']);
} elseif ($option['value_type'] == 'attribute') {
$value = $attribute_value;
} else {
$value = $option['value'];
}
break;
}
if ($value === null && $custom_attribute->getDefaultValue()) {
switch ($custom_attribute->getDefaultValue()) {
case 'price':
if (in_array($_product->getTypeId(), array(Mage_Catalog_Model_Product_Type::TYPE_GROUPED, Mage_Catalog_Model_Product_Type::TYPE_BUNDLE))) {
$value = $store->convertPrice($_product->getMinimalPrice(), false, false);
} else {
$value = $store->convertPrice($_product->getPrice(), false, false);
}
break;
case 'store_price':
$value = $store->convertPrice($_product->getFinalPrice(), false, false);
break;
case 'parent_url':
if (($parent_product = $this->getFeed()->getParentProduct($_product, $products)) && $parent_product->getEntityId() > 0) {
$value = $parent_product->getProductUrl(false);
break;
}
$value = $_product->getProductUrl(false);
break;
case 'image':
case 'gallery':
case 'media_gallery':
if (!$_product->hasData('product_base_image')) {
$_prod = Mage::getModel('catalog/product')->load($_product->getId());
try {
if ($image_width || $image_height) {
$image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image')->resize($image_width, $image_height);
} else {
$image_url = (string) Mage::helper('catalog/image')->init($_prod, 'image');
}
} catch (Exception $e) {
$image_url = '';
}
$_product->setData('product_base_image', $image_url);
$value = $image_url;
} else {
$value = $_product->getData('product_base_image');
}
break;
case 'url':
$value = $_product->getProductUrl(false);
break;
case 'qty':
$value = ceil(Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty());
if (!$value || $value == '' || $value == null) {
$value = 0;
}
// if($stock_item = $stock_collection->getItemByColumnValue('product_id', $_product->getId())){
//
// $value = ceil($stock_collection->getItemByColumnValue('product_id', $_product->getId())->getQty());
//
// }else{
//
// $value = 0;
//
// }
break;
case 'category':
$value = $product->getCategory();
break;
default:
$value = $_product->getData($custom_attribute->getDefaultValue());
}
}
}
} elseif ($attribute_model = $_product->getResource()->getAttribute($attribute_code)) {
switch ($attribute_model->getFrontendInput()) {
case 'select':
case 'multiselect':
$value = implode(', ', (array) $_product->getAttributeText($attribute_code));
break;
default:
$value = $_product->getData($attribute_code);
break;
}
}
break;
}
if ($value && !$product->getData($attribute_code)) {
$product->setData($attribute_code, $value);
}
}
$product->setDescription(strip_tags(preg_replace('/<br.*?>/s', "\r\n", $_product->getDescription())));
$product->setShortDescription(strip_tags(preg_replace('/<br.*?>/s', "\r\n", $_product->getShortDescription())));
$product->setQty(ceil(Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()));
fwrite($fp, parent::setVars($content, $product) . "\r\n");
}
fclose($fp);
}