本文整理汇总了PHP中Varien_Object::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Object::getName方法的具体用法?PHP Varien_Object::getName怎么用?PHP Varien_Object::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Object
的用法示例。
在下文中一共展示了Varien_Object::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Renders grid column
*
* @param Varien_Object $row
* @return string
*/
public function render(Varien_Object $row)
{
$action_name = $this->getRequest()->getActionName();
if ($action_name == 'exportCsv' || $action_name == 'exportXml') {
return $row->getName();
}
$href = $this->getUrl('*/catalog_product/edit', array('store' => $this->getRequest()->getParam('store'), 'id' => $row->getId()));
$html = '<a href="' . $href . '">' . $row->getName() . '</a>';
return $html;
}
示例2: render
public function render(Varien_Object $row)
{
$content = "";
$content .= "<b>" . $row->getName() . ' [' . $row->getStoreCode() . ']</b><br>';
$content .= Mage::helper('pointofsale')->getStoreDescription($row);
return $content;
}
示例3: _checkPost
protected function _checkPost($requireAccessToken = true)
{
if (Mage::helper('storealerts')->isDebug() || Mage::app()->getStore()->isCurrentlySecure()) {
if ($data = $this->getRequest()->getPost()) {
$dataObj = new Varien_Object();
$dataObj->setData($data);
$deviceToken = $dataObj->getDeviceToken();
$name = $dataObj->getName();
$username = $dataObj->getUsername();
$password = $dataObj->getPassword();
$accessToken = $requireAccessToken ? $dataObj->getAccessToken() : true;
if ($deviceToken && $username && $password && $accessToken) {
$admin = Mage::helper('storealerts')->login($username, $password);
if ($admin->getId()) {
try {
$datetime = date("Y-m-d H:i:s");
$preference = Mage::getModel('extensions_store_storealerts/preference');
$preference->load($admin->getId());
if (!$preference->getId()) {
$preference->setUserId($admin->getId())->setCreatedAt($datetime)->setUpdatedAt($datetime)->save();
}
$dataObj->setPreference($preference);
$device = Mage::getModel('extensions_store_storealerts/device');
$device->load($deviceToken, 'device_token');
if (!$device->getId()) {
$device->setName($name)->setDeviceToken($deviceToken)->setUserId($admin->getId())->setCreatedAt($datetime)->setUpdatedAt($datetime)->save();
}
$dataObj->setDevice($device);
$result['error'] = false;
$result['data'] = $dataObj;
} catch (Exception $e) {
$result['error'] = true;
$result['data'] = $e->getMessage();
}
} else {
$result['error'] = true;
$result['data'] = 'Could not login admin';
}
} else {
$result['error'] = true;
$result['data'] = 'No device token, username, password or access token.';
}
} else {
$result['error'] = true;
$result['data'] = 'No admin login credentials posted.';
}
} else {
$result['error'] = true;
$result['data'] = 'Request is not over HTTPS.';
}
if ($result['error'] === true) {
$errorMessage = $result['data'];
Mage::helper('storealerts')->log($errorMessage);
}
return $result;
}
示例4: validate
public function validate(Varien_Object $object)
{
if (!$object instanceof Mage_Sales_Model_Quote_Item) {
return false;
}
if ($this->getValue() && stristr($object->getName(), $this->getValue())) {
return true;
}
return false;
}
示例5: beforeSave
/**
* Before save
*
* @param Varien_Object $object
* @return Mage_Catalog_Model_Resource_Product_Attribute_Backend_Urlkey
*/
public function beforeSave($object)
{
$attributeName = $this->getAttribute()->getName();
$urlKey = $object->getData($attributeName);
if ($urlKey == '') {
$urlKey = $object->getName();
}
$object->setData($attributeName, $object->formatUrlKey($urlKey));
return $this;
}
示例6: postAction
public function postAction()
{
$post = $this->getRequest()->getPost();
if ($post) {
$translate = Mage::getSingleton('core/translate');
/* @var $translate Mage_Core_Model_Translate */
$translate->setTranslateInline(false);
try {
$postObject = new Varien_Object();
$postObject->setData($post);
$error = false;
if (!Zend_Validate::is(trim($post['name']), 'NotEmpty')) {
$error = true;
}
if (!Zend_Validate::is(trim($post['comment']), 'NotEmpty')) {
$error = true;
}
if (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) {
$error = true;
}
if (Zend_Validate::is(trim($post['hideit']), 'NotEmpty')) {
$error = true;
}
$akismet = Mage::getSingleton('mgt_akismet/akismet');
if ($akismet->isActive()) {
$data = array('name' => $postObject->getName(), 'email' => $postObject->getEmail(), 'comment' => $postObject->getComment());
if ($akismet->isSpam($data)) {
$error = true;
}
}
if ($error) {
throw new Exception();
}
$mailTemplate = Mage::getModel('core/email_template');
/* @var $mailTemplate Mage_Core_Model_Email_Template */
$mailTemplate->setDesignConfig(array('area' => 'frontend'))->setReplyTo($post['email'])->sendTransactional(Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE), Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER), Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT), null, array('data' => $postObject));
if (!$mailTemplate->getSentSuccess()) {
throw new Exception();
}
$translate->setTranslateInline(true);
Mage::getSingleton('customer/session')->addSuccess(Mage::helper('contacts')->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.'));
$this->_redirect('*/*/');
return;
} catch (Exception $e) {
$translate->setTranslateInline(true);
Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later'));
$this->_redirect('*/*/');
return;
}
} else {
$this->_redirect('*/*/');
}
}
示例7: __construct
/**
* initialize
*
* @access public
* @author Ultimate Module Creator
*/
public function __construct()
{
$customerSession = Mage::getSingleton('customer/session');
parent::__construct();
$data = Mage::getSingleton('customer/session')->getPopupCommentFormData(true);
$data = new Varien_Object($data);
// add logged in customer name as nickname
if (!$data->getName()) {
$customer = $customerSession->getCustomer();
if ($customer && $customer->getId()) {
$data->setName($customer->getFirstname());
$data->setEmail($customer->getEmail());
}
}
$this->setAllowWriteCommentFlag($customerSession->isLoggedIn() || Mage::getStoreConfigFlag('iou_ultimatepopup/popup/allow_guest_comment'));
if (!$this->getAllowWriteCommentFlag()) {
$this->setLoginLink(Mage::getUrl('customer/account/login/', array(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME => Mage::helper('core')->urlEncode(Mage::getUrl('*/*/*', array('_current' => true)) . '#comment-form'))));
}
$this->setCommentData($data);
}
示例8: renderExport
public function renderExport(Varien_Object $_item)
{
$res = '';
$prefix = ',';
$separator = ':';
$helper = Mage::helper('mageworx_customerplus');
$res .= $_item->getName();
$res .= $prefix . $this->helper('mageworx_customerplus')->__('SKU') . $separator . implode($prefix, Mage::helper('catalog')->splitSku($helper->getSku($_item)));
$_orderOptions = $helper->getOrderOptions($_item);
if ($_orderOptions) {
foreach ($_orderOptions as $_option) {
$res .= $prefix . $_option['label'] . $separator;
if (isset($_option['custom_view']) && $_option['custom_view']) {
$res .= $helper->getCustomizedOptionValue($_option);
} else {
$res .= Mage::helper('core/string')->truncate($_option['value'], 55, '');
}
}
}
return $res;
}
示例9: _getItemsXml
/**
* Retrieve quote items in XML format
*
* @return string
*/
protected function _getItemsXml()
{
$xml = <<<EOT
<items>
EOT;
foreach ($this->getQuote()->getAllItems() as $item) {
if ($item->getParentItem()) {
continue;
}
$taxClass = $item->getTaxClassId() == 0 ? 'none' : $item->getTaxClassId();
$weight = (double) $item->getWeight();
$weightUnit = self::ITEM_WEIGHT_UNIT;
$unitPrice = $item->getBaseCalculationPrice();
if (Mage::helper('Mage_Weee_Helper_Data')->includeInSubtotal()) {
$unitPrice += $item->getBaseWeeeTaxAppliedAmount();
}
$xml .= <<<EOT
<item>
<merchant-item-id><![CDATA[{$item->getSku()}]]></merchant-item-id>
<item-name><![CDATA[{$item->getName()}]]></item-name>
<item-description><![CDATA[{$item->getDescription()}]]></item-description>
<unit-price currency="{$this->getCurrency()}">{$unitPrice}</unit-price>
<quantity>{$item->getQty()}</quantity>
<item-weight unit="{$weightUnit}" value="{$weight}" />
<tax-table-selector>{$taxClass}</tax-table-selector>
{$this->_getDigitalContentXml($item->getIsVirtual())}
{$this->_getMerchantPrivateItemDataXml($item)}
</item>
EOT;
}
$billingAddress = $this->getQuote()->getBillingAddress();
$shippingAddress = $this->getQuote()->getShippingAddress();
$shippingDiscount = (double) $shippingAddress->getBaseDiscountAmount();
$billingDiscount = (double) $billingAddress->getBaseDiscountAmount();
$discount = $billingDiscount + $shippingDiscount;
// Exclude shipping discount
// Discount is negative value
$discount += $shippingAddress->getBaseShippingDiscountAmount();
$discountItem = new Varien_Object(array('price' => $discount, 'name' => $this->__('Cart Discount'), 'description' => $this->__('A virtual item to reflect the discount total')));
Mage::dispatchEvent('google_checkout_discount_item_price', array('quote' => $this->getQuote(), 'discount_item' => $discountItem));
$discount = $discountItem->getPrice();
if ($discount) {
$xml .= <<<EOT
<item>
<merchant-item-id>_INTERNAL_DISCOUNT_</merchant-item-id>
<item-name>{$discountItem->getName()}</item-name>
<item-description>{$discountItem->getDescription()}</item-description>
<unit-price currency="{$this->getCurrency()}">{$discount}</unit-price>
<quantity>1</quantity>
<item-weight unit="{$weightUnit}" value="0.00" />
<tax-table-selector>none</tax-table-selector>
{$this->_getDigitalContentXml($this->getQuote()->isVirtual())}
</item>
EOT;
}
$hiddenTax = $shippingAddress->getBaseHiddenTaxAmount() + $billingAddress->getBaseHiddenTaxAmount();
if ($hiddenTax) {
$xml .= <<<EOT
<item>
<merchant-item-id>_INTERNAL_TAX_</merchant-item-id>
<item-name>{$this->__('Discount Tax')}</item-name>
<item-description>{$this->__('A virtual item to reflect the tax total')}</item-description>
<unit-price currency="{$this->getCurrency()}">{$hiddenTax}</unit-price>
<quantity>1</quantity>
<item-weight unit="{$weightUnit}" value="0.00" />
<tax-table-selector>none</tax-table-selector>
{$this->_getDigitalContentXml($this->getQuote()->isVirtual())}
</item>
EOT;
}
$xml .= <<<EOT
</items>
EOT;
return $xml;
}
示例10: buildNodeName
/**
* Get category name
*
* @param Varien_Object $node
* @return string
*/
public function buildNodeName($node)
{
$result = $this->htmlEscape($node->getName());
if ($this->_withProductCount) {
$result .= ' (' . $node->getProductCount() . ')';
}
return $result;
}
示例11: generatePath
/**
* Generate either id path, request path or target path for product and/or category
*
* For generating id or system path, either product or category is required
* For generating request path - category is required
* $parentPath used only for generating category path
*
* @param string $type
* @param Varien_Object $product
* @param Varien_Object $category
* @param string $parentPath
* @return string
* @throws Mage_Core_Exception
*/
public function generatePath($type = 'target', $product = null, $category = null, $parentPath = null)
{
if (!$product && !$category) {
Mage::throwException(Mage::helper('core')->__('Please specify either a category or a product, or both.'));
}
// generate id_path
if ('id' === $type) {
if (!$product) {
return 'category/' . $category->getId();
}
if ($category && $category->getLevel() > 1) {
return 'product/' . $product->getId() . '/' . $category->getId();
}
return 'product/' . $product->getId();
}
// generate request_path
if ('request' === $type) {
// for category
if (!$product) {
if ($category->getUrlKey() == '') {
$urlKey = $this->getCategoryModel()->formatUrlKey($category->getName());
} else {
$urlKey = $this->getCategoryModel()->formatUrlKey($category->getUrlKey());
}
$categoryUrlSuffix = $this->getCategoryUrlSuffix($category->getStoreId());
if (null === $parentPath) {
$parentPath = $this->getResource()->getCategoryParentPath($category);
} elseif ($parentPath == '/') {
$parentPath = '';
}
$parentPath = Mage::helper('catalog/category')->getCategoryUrlPath($parentPath, true, $category->getStoreId());
return $this->getUnusedPath($category->getStoreId(), $parentPath . $urlKey . $categoryUrlSuffix, $this->generatePath('id', null, $category));
}
// for product & category
if (!$category) {
Mage::throwException(Mage::helper('core')->__('A category object is required for determining the product request path.'));
// why?
}
if ($product->getUrlKey() == '') {
$urlKey = $this->getProductModel()->formatUrlKey($product->getName());
} else {
$urlKey = $this->getProductModel()->formatUrlKey($product->getUrlKey());
}
$productUrlSuffix = $this->getProductUrlSuffix($category->getStoreId());
if ($category->getLevel() > 1) {
// To ensure, that category has url path either from attribute or generated now
$this->_addCategoryUrlPath($category);
$categoryUrl = Mage::helper('catalog/category')->getCategoryUrlPath($category->getUrlPath(), false, $category->getStoreId());
return $this->getUnusedPath($category->getStoreId(), $categoryUrl . '/' . $urlKey . $productUrlSuffix, $this->generatePath('id', $product, $category));
}
// for product only
return $this->getUnusedPath($category->getStoreId(), $urlKey . $productUrlSuffix, $this->generatePath('id', $product));
}
// generate target_path
if (!$product) {
return 'catalog/category/view/id/' . $category->getId();
}
if ($category && $category->getLevel() > 1) {
return 'catalog/product/view/id/' . $product->getId() . '/category/' . $category->getId();
}
return 'catalog/product/view/id/' . $product->getId();
}
示例12: getProductRequestPath
/**
* Get unique product request path
*
* @param Varien_Object $product
* @param Varien_Object $category
* @return string
*/
public function getProductRequestPath($product, $category)
{
if ($product->getUrlKey() == '') {
$urlKey = $this->getProductModel()->formatUrlKey($product->getName());
} else {
$urlKey = $this->getProductModel()->formatUrlKey($product->getUrlKey());
}
$storeId = $category->getStoreId();
$suffix = $this->getProductUrlSuffix($storeId);
$idPath = $this->generatePath('id', $product, $category);
/**
* Prepare product base request path
*/
if ($category->getLevel() > 1) {
// To ensure, that category has path either from attribute or generated now
$this->_addCategoryUrlPath($category);
$categoryUrl = Mage::helper('catalog/category')->getCategoryUrlPath($category->getUrlPath(), false, $storeId);
$requestPath = $categoryUrl . '/' . $urlKey;
} else {
$requestPath = $urlKey;
}
if (strlen($requestPath) > self::MAX_REQUEST_PATH_LENGTH + self::ALLOWED_REQUEST_PATH_OVERFLOW) {
$requestPath = substr($requestPath, 0, self::MAX_REQUEST_PATH_LENGTH);
}
$this->_rewrite = null;
/**
* Check $requestPath should be unique
*/
if (isset($this->_rewrites[$idPath])) {
$this->_rewrite = $this->_rewrites[$idPath];
$existingRequestPath = $this->_rewrites[$idPath]->getRequestPath();
$existingRequestPath = str_replace($suffix, '', $existingRequestPath);
if ($existingRequestPath == $requestPath) {
return $requestPath . $suffix;
}
/**
* Check if existing request past can be used
*/
if (!empty($requestPath) && strpos($existingRequestPath, $requestPath) !== false) {
$existingRequestPath = str_replace($requestPath, '', $existingRequestPath);
if (preg_match('#^-([0-9]+)$#i', $existingRequestPath)) {
return $this->_rewrites[$idPath]->getRequestPath();
}
}
/**
* check if current generated request path is one of the old paths
*/
$fullPath = $requestPath . $suffix;
$finalOldTargetPath = $this->getResource()->findFinalTargetPath($fullPath, $storeId);
if ($finalOldTargetPath && $finalOldTargetPath == $idPath) {
$this->getResource()->deleteRewrite($fullPath, $storeId);
return $fullPath;
}
}
/**
* Check 2 variants: $requestPath and $requestPath . '-' . $productId
*/
$validatedPath = $this->getResource()->checkRequestPaths(array($requestPath . $suffix, $requestPath . '-' . $product->getId() . $suffix), $storeId);
if ($validatedPath) {
return $validatedPath;
}
/**
* Use unique path generator
*/
return $this->getUnusedPath($storeId, $requestPath . $suffix, $idPath);
}
示例13: matchesCriterion
/**
* Test if message matches criterion
*
* @param Varien_Object $criterion Matching criterion
* @return boolean
*/
public function matchesCriterion(Varien_Object $criterion)
{
$meta = $this->getMeta();
$name = isset($meta['name']) ? $meta['name'] : null;
return $criterion->getName() && $criterion->getName() == $name;
}
示例14: _addRegularItem
/**
* Add a usual line item with amount and qty
*
* @param Varien_Object $salesItem
* @return Varien_Object
*/
protected function _addRegularItem(Varien_Object $salesItem)
{
if ($this->_salesEntity instanceof Mage_Sales_Model_Order) {
$qty = (int) $salesItem->getQtyOrdered();
$amount = (double) $salesItem->getBasePrice();
// TODO: nominal item for order
} else {
$qty = (int) $salesItem->getTotalQty();
$amount = $salesItem->isNominal() ? 0 : (double) $salesItem->getBaseCalculationPrice();
}
// workaround in case if item subtotal precision is not compatible with PayPal (.2)
$subAggregatedLabel = '';
if ($amount - round($amount, 2)) {
$amount = $amount * $qty;
$subAggregatedLabel = ' x' . $qty;
$qty = 1;
}
// aggregate item price if item qty * price does not match row total
if ($amount * $qty != $salesItem->getBaseRowTotal()) {
$amount = (double) $salesItem->getBaseRowTotal();
$subAggregatedLabel = ' x' . $qty;
$qty = 1;
}
return $this->addItem($salesItem->getName() . $subAggregatedLabel, $qty, $amount, $salesItem->getSku());
}
示例15: sendAction
public function sendAction()
{
// todo check validity;
$template = new Varien_Object();
$template->setData($this->getRequest()->getParams());
$customersIds = $this->getRequest()->getParam('customers');
$ordersIds = $this->getRequest()->getParam('orders');
if ($customersIds) {
$collection = Mage::getResourceModel('customer/customer_collection')->addNameToSelect()->addAttributeToSelect('email')->addFieldToFilter('entity_id', array('in' => explode(',', $customersIds)));
$cnt = 0;
foreach ($collection as $customer) {
$vars = array('customer' => $customer, 'store' => Mage::app()->getStore($customer->getStoreId()), 'order' => new Varien_Object());
$res = $this->send($customer->getEmail(), $customer->getName(), $template, $vars);
if (true === $res) {
$cnt++;
} else {
Mage::getSingleton('adminhtml/session')->addError($res);
}
}
//foreach
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('amemail')->__('%s email(s) have been sent.', $cnt));
// show customer page if we have only one order
if (1 == count($customersIds)) {
return $this->_redirect('customer/edit', array('id' => $customersIds[0]));
}
return $this->_redirect('customer/index');
} elseif ($ordersIds) {
$collection = Mage::getResourceModel('sales/order_collection')->addFieldToFilter('entity_id', array('in' => explode(',', $ordersIds)));
if (version_compare(Mage::getVersion(), '1.6.2') < 0) {
$collection = 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');
}
$cnt = 0;
foreach ($collection as $order) {
$customer = new Varien_Object();
if ($order->getCustomerFirstname() || $order->getCustomerLastname()) {
$customer->setName($order->getCustomerFirstname() . ' ' . $order->getCustomerLastname());
} else {
$customer->setName($order->getShippingFirstname() . ' ' . $order->getShippingLastname());
}
$customer->setId($order->getCustomerId());
$vars = array('order' => $order, 'customer' => $customer, 'store' => Mage::app()->getStore($order->getStoreId()));
$res = $this->send($order->getCustomerEmail(), $customer->getName(), $template, $vars);
if (true === $res) {
$cnt++;
} else {
Mage::getSingleton('adminhtml/session')->addError($res);
}
}
//foreach
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('amemail')->__('%s email(s) have been sent.', $cnt));
// show order page if we have only one order
if (1 == count($ordersIds)) {
return $this->_redirect('sales_order/view', array('order_id' => $ordersIds[0]));
}
return $this->_redirect('sales_order/index');
}
// no ids
return $this->_redirect('dashboard/index');
}