本文整理匯總了PHP中Varien_Object::getValue方法的典型用法代碼示例。如果您正苦於以下問題:PHP Varien_Object::getValue方法的具體用法?PHP Varien_Object::getValue怎麽用?PHP Varien_Object::getValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Varien_Object
的用法示例。
在下文中一共展示了Varien_Object::getValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: formatValue
/**
* Format total value based on order currency
*
* @param Varien_Object $total
* @return string
*/
public function formatValue($total)
{
if (!$total->getIsFormated()) {
return $this->helper('adminhtml/sales')->displayPrices($this->getOrder(), $total->getBaseValue(), $total->getValue());
}
return $total->getValue();
}
示例2: checkProductBuyState
public function checkProductBuyState($product = null)
{
Mage_Catalog_Model_Product_Type_Abstract::checkProductBuyState($product);
$product = $this->getProduct($product);
$productOptionIds = $this->getOptionsIds($product);
$productSelections = $this->getSelectionsCollection($productOptionIds, $product);
$selectionIds = $product->getCustomOption('bundle_selection_ids');
$selectionIds = unserialize($selectionIds->getValue());
$buyRequest = $product->getCustomOption('info_buyRequest');
$buyRequest = new Varien_Object(unserialize($buyRequest->getValue()));
$bundleOption = $buyRequest->getBundleOption();
if (empty($bundleOption)) {
Mage::throwException($this->getSpecifyOptionMessage());
}
$skipSaleableCheck = Mage::helper('catalog/product')->getSkipSaleableCheck();
foreach ($selectionIds as $selectionId) {
/* @var $selection Mage_Bundle_Model_Selection */
$selection = $productSelections->getItemById($selectionId);
if (!$selection || !$selection->isSalable() && !$skipSaleableCheck) {
Mage::throwException(Mage::helper('bundle')->__('Selected required options are not available.'));
}
}
/*
$product->getTypeInstance(true)->setStoreFilter($product->getStoreId(), $product);
$optionsCollection = $this->getOptionsCollection($product);
foreach ($optionsCollection->getItems() as $option) {
if ($option->getRequired() && empty($bundleOption[$option->getId()])) {
Mage::throwException(
Mage::helper('bundle')->__('Required options are not selected.')
);
}
}
*/
return $this;
}
示例3: _getParams
/**
* @return mixed
*/
protected function _getParams()
{
if (!Mage::registry(self::REGISTRY_KEY_PARAMS)) {
$request = Mage::app()->getRequest();
$params = array('host' => $request->getServer('HTTP_HOST'), 'port' => $request->getServer('SERVER_PORT'), 'full_action_name' => $this->getFullActionName());
$uriParams = $this->_getUriParams();
foreach ($request->getParams() as $requestParam => $requestParamValue) {
if (!$requestParamValue) {
continue;
}
foreach ($uriParams as $uriParam) {
if ($this->_matchUriParam($uriParam, $requestParam)) {
$params['uri_' . $requestParam] = $requestParamValue;
break;
}
}
}
if (Mage::getStoreConfig(self::XML_PATH_CUSTOMER_GROUPS)) {
$customerSession = Mage::getSingleton('customer/session');
$params['customer_group_id'] = $customerSession->getCustomerGroupId();
}
// edit parameters via event
$parameters = new Varien_Object();
$parameters->setValue($params);
Mage::dispatchEvent('fpc_helper_collect_params', array('parameters' => $parameters));
$params = $parameters->getValue();
Mage::register(self::REGISTRY_KEY_PARAMS, serialize($params));
}
return Mage::registry(self::REGISTRY_KEY_PARAMS);
}
示例4: setChildsBasedOnGroup
/**
* @param $group Webguys_Easytemplate_Model_Group
* @return $this
*/
public function setChildsBasedOnGroup($group, $parent = null)
{
if (!$this->countChildren()) {
Varien_Profiler::start('easytemplate_template_rendering');
/** @var $configModel Webguys_Easytemplate_Model_Input_Parser */
$configModel = Mage::getSingleton('easytemplate/input_parser');
$position = 1;
$time = Mage::app()->getLocale()->storeTimeStamp(Mage::app()->getStore()->getId());
/** @var $template Webguys_Easytemplate_Model_Template */
foreach ($group->getTemplateCollection($parent) as $template) {
$templateCode = $template->getCode();
if ($model = $configModel->getTemplate($templateCode)) {
$active = $template->getActive();
$validFrom = $template->getValidFrom() ? strtotime($template->getValidFrom()) : false;
$validTo = $template->getValidTo() ? strtotime($template->getValidTo()) : false;
if ($validFrom !== false || $validTo !== false) {
$this->_cachingAllowed = false;
}
Varien_Profiler::start('easytemplate_template_rendering_' . $templateCode);
if ($active && (!$validFrom || $validFrom <= $time) && (!$validTo || $validTo >= $time)) {
/** @var $childBlock Webguys_Easytemplate_Block_Template */
$childBlock = $this->getLayout()->createBlock($model->getType());
$childBlock->setTemplate($model->getTemplate());
$childBlock->setTemplateModel($template);
$childBlock->setTemplateCode($templateCode);
$childBlock->setGroup($group);
/** @var $field Webguys_Easytemplate_Model_Input_Parser_Field */
foreach ($model->getFields() as $field) {
$fieldCode = $field->getCode();
Varien_Profiler::start('easytemplate_template_rendering_' . $templateCode . '_field_' . $fieldCode);
/** @var $inputValidator Webguys_Easytemplate_Model_Input_Renderer_Validator_Base */
$inputValidator = $field->getInputRendererValidator();
$inputValidator->setTemplate($template);
$inputValidator->setField($field);
$frontendValue = $inputValidator->prepareForFrontend($template->getFieldData($fieldCode));
if ($frontendValue) {
$valueTransport = new Varien_Object();
$valueTransport->setValue($frontendValue);
Mage::dispatchEvent('easytemplate_frontend_prepared_var', array('template' => $template, 'template_model' => $model, 'field' => $field, 'block' => $childBlock, 'validator' => $inputValidator, 'value' => $valueTransport));
$childBlock->setData($fieldCode, $valueTransport->getValue());
}
Varien_Profiler::stop('easytemplate_template_rendering_' . $templateCode . '_field_' . $fieldCode);
}
$this->setChild('block_' . $position . '_' . $templateCode, $childBlock);
$position++;
}
Varien_Profiler::stop('easytemplate_template_rendering_' . $templateCode);
}
}
Varien_Profiler::stop('easytemplate_template_rendering');
}
return $this;
}
示例5: testFpcHelperCollectParams
/**
* @test
* @loadFixture fpc_helper_collect_params.yaml
*/
public function testFpcHelperCollectParams()
{
Mage::app()->getRequest()->setRouteName('catalog');
Mage::app()->getRequest()->setControllerName('category');
Mage::app()->getRequest()->setActionName('view');
/** @var Mage_Catalog_Model_Session $catalogSession */
$catalogSession = Mage::getSingleton('catalog/session');
$catalogSession->setData('fpc', 'cool');
$expectedResult = array('fpc' => 'cool', 'store' => Mage::app()->getStore(true)->getCode(), 'currency' => Mage::app()->getStore()->getCurrentCurrencyCode(), 'design' => Mage::getDesign()->getPackageName() . '_' . Mage::getDesign()->getTheme('template'), 'session_fpc' => 'cool');
$params = array('fpc' => 'cool');
$object = new Varien_Object();
$object->setValue($params);
Mage::dispatchEvent('fpc_helper_collect_params', array('parameters' => $object));
$this->assertEquals($expectedResult, $object->getValue());
}
示例6: _formatPrice
/**
* Format price using order currency
*
* @param Varien_Object $total
* @return string
*/
protected function _formatPrice($total)
{
if (!$total->getIsFormated()) {
return Mage::helper('Mage_XmlConnect_Helper_Customer_Order')->formatPrice($this, $total->getValue());
}
return $total->getValue();
}
示例7: _getPermalinkPattern
/**
* Retrieve the pattern used to match the URL to the permalink structure
*
* @return string
*/
protected function _getPermalinkPattern()
{
$routerHelper = Mage::helper('wordpress/router');
if ($structure = $this->_getExplodedPermalinkStructure()) {
$lastPiece = $structure[count($structure) - 1];
if ($lastPiece === '/') {
array_pop($structure);
}
foreach ($structure as $i => $part) {
if (preg_match('/^\\%[a-zA-Z0-9_-]{1,}\\%$/', $part)) {
$part = trim($part, '%');
if ($part === 'year') {
$part = '[1-2]{1}[0-9]{3}';
} else {
if ($part === 'monthnum') {
$part = '[0-1]{1}[0-9]{1}';
} else {
if ($part === 'day') {
$part = '[0-3]{1}[0-9]{1}';
} else {
if ($part === 'hour') {
$part = '[0-2]{1}[0-9]{1}';
} else {
if ($part === 'minute') {
$part = '[0-5]{1}[0-9]{1}';
} else {
if ($part === 'second') {
$part = '[0-5]{1}[0-9]{1}';
} else {
if ($part === 'post_id') {
$part = '[0-9]{1,}';
} else {
if ($part === 'postname') {
$part = $routerHelper->getPermalinkStringRegex();
} else {
if ($part === 'category') {
$part = $routerHelper->getPermalinkStringRegex('\\/');
} else {
if ($part === 'author') {
$part = $routerHelper->getPermalinkStringRegex();
} else {
$response = new Varien_Object(array('value' => false));
Mage::dispatchEvent('wordpress_permalink_segment_unknown_pattern', array('response' => $response, 'segment' => $part));
if ($response->getValue() !== false) {
$part = $response->getValue();
}
}
}
}
}
}
}
}
}
}
}
$part = '(' . $part . ')';
} else {
$part = preg_replace('/([.|\\\\|\\/]{1})/i', '\\\\$1', $part);
}
$structure[$i] = $part;
}
return '^' . implode('', $structure) . '$';
}
return false;
}
示例8: moveQuoteItem
/**
* Move quote item to another items store
*
* @param mixed $item
* @param string $mogeTo
* @return Mage_Adminhtml_Model_Sales_Order_Create
*/
public function moveQuoteItem($item, $moveTo, $qty)
{
if ($item = $this->_getQuoteItem($item)) {
switch ($moveTo) {
case 'order':
$info = array();
if ($info = $item->getOptionByCode('info_buyRequest')) {
$info = new Varien_Object(unserialize($info->getValue()));
$info->setOptions($this->_prepareOptionsForRequest($item));
}
$product = Mage::getModel('catalog/product')->setStoreId($this->getQuote()->getStoreId())->load($item->getProduct()->getId());
$product->setSkipCheckRequiredOption(true);
$newItem = $this->getQuote()->addProduct($product, $info);
if (is_string($newItem)) {
Mage::throwException($newItem);
}
$product->unsSkipCheckRequiredOption();
$newItem->checkData();
$newItem->setQty($qty);
break;
case 'cart':
if (($cart = $this->getCustomerCart()) && is_null($item->getOptionByCode('additional_options'))) {
//options and info buy request
$product = Mage::getModel('catalog/product')->setStoreId($this->getQuote()->getStoreId())->load($item->getProduct()->getId());
$product->setSkipCheckRequiredOption(true);
$info = array();
if ($info = $item->getOptionByCode('info_buyRequest')) {
$info = new Varien_Object(unserialize($info->getValue()));
$info->setOptions($this->_prepareOptionsForRequest($item));
} else {
$info = new Varien_Object(array('product_id' => $product->getId(), 'qty' => $qty, 'options' => $this->_prepareOptionsForRequest($item)));
}
$cartItem = $cart->addProduct($product, $info);
if (is_string($cartItem)) {
Mage::throwException($cartItem);
}
$product->unsSkipCheckRequiredOption();
$cartItem->setQty($qty);
$cartItem->setPrice($item->getProduct()->getPrice());
$cart->collectTotals()->save();
}
break;
case 'wishlist':
if ($wishlist = $this->getCustomerWishlist()) {
$wishlist->addNewItem($item->getProduct()->getId());
}
break;
case 'comparelist':
break;
default:
break;
}
$this->getQuote()->removeItem($item->getId());
$this->setRecollect(true);
}
return $this;
}
示例9: getPermalink
/**
* return the permalink based on permalink structure
* which is defined in WP Admin
*
* @param Fishpig_Wordpress_Model_Post
* @return string
*/
public function getPermalink(Fishpig_Wordpress_Model_Post $post)
{
if ($this->useGuidLinks()) {
return $this->getUrl('?p=' . $post->getId());
} else {
$structure = $this->_getExplodedPermalinkStructure();
if (count($structure) > 0) {
$url = array();
foreach ($structure as $part) {
if (preg_match('/^\\%[a-zA-Z0-9_]{1,}\\%$/', $part)) {
$part = trim($part, '%');
if ($part === 'year') {
$url[] = $post->getPostDate('Y');
} else {
if ($part === 'monthnum') {
$url[] = $post->getPostDate('m');
} else {
if ($part === 'day') {
$url[] = $post->getPostDate('d');
} else {
if ($part === 'hour') {
$url[] = $post->getPostDate('H');
} else {
if ($part === 'minute') {
$url[] = $post->getPostDate('i');
} else {
if ($part === 'second') {
$url[] = $post->getPostDate('s');
} else {
if ($part === 'post_id') {
$url[] = $post->getId();
} else {
if ($part === 'postname') {
$url[] = urldecode($post->getPostName());
} else {
if ($part === 'category') {
$url[] = $this->_getPermalinkCategoryPortion($post);
} else {
if ($part === 'author') {
} else {
$response = new Varien_Object(array('value' => false));
Mage::dispatchEvent('wordpress_permalink_segment_unknown_getpermalink', array('response' => $response, 'post' => $post, 'segment' => $part));
if ($response->getValue() !== false) {
$url[] = $response->getValue();
}
}
}
}
}
}
}
}
}
}
}
} else {
if ($part === '/') {
$partCount = count($url);
if ($partCount > 0 && $url[$partCount - 1] === $part) {
continue;
}
}
$url[] = $part;
}
}
if ($this->permalinkHasTrainingSlash()) {
$url[count($url) - 1] .= '/';
}
return $this->getUrl(implode('', $url));
}
}
}
示例10: formatTotalValue
/**
* Format total value based on order currency
*
* @param Varien_Object $total
* @return string
*/
protected function formatTotalValue($total)
{
if (!$total->getIsFormated()) {
return Mage::helper('core')->currency($total->getValue(), true, false);
}
return $total->getValue();
}
示例11: cartHasQuoteItems
/**
* Checks if cart has quote items in it, if so returns true
* this is used by lock quantity and lock shipping address
* and method
*/
public function cartHasQuoteItems()
{
$cart = Mage::getSingleton('checkout/cart')->getQuote();
foreach ($cart->getAllItems() as $item) {
$buyrequest = $item->getOptionByCode('info_buyRequest');
$buyrequest = new Varien_Object(unserialize($buyrequest->getValue()));
if ($buyrequest->getData(ITwebexperts_Request4quote_Model_Quote::QUOTE_ID_OPTION)) {
return $buyrequest->getData(ITwebexperts_Request4quote_Model_Quote::QUOTE_ID_OPTION);
}
}
return false;
}
示例12: updateQtyOption
/**
* Method is needed for specific actions to change given quote options values
* according current product type logic
* Example: the cataloginventory validation of decimal qty can change qty to int,
* so need to change quote item qty option value too.
*
* @param array $options
* @param Varien_Object $option
* @param mixed $value
* @param Mage_Catalog_Model_Product $product
* @return Mage_Bundle_Model_Product_Type
*/
public function updateQtyOption($options, Varien_Object $option, $value, $product = null)
{
$optionProduct = $option->getProduct($product);
$optionUpdateFlag = $option->getHasQtyOptionUpdate();
$optionCollection = $this->getOptionsCollection($product);
$selections = $this->getSelectionsCollection($optionCollection->getAllIds(), $product);
foreach ($selections as $selection) {
if ($selection->getProductId() == $optionProduct->getId()) {
foreach ($options as &$option) {
if ($option->getCode() == 'selection_qty_' . $selection->getSelectionId()) {
if ($optionUpdateFlag) {
$option->setValue(intval($option->getValue()));
} else {
$option->setValue($value);
}
}
}
}
}
return $this;
}
示例13: httpResponseSendBefore
/**
* @param $observer
*/
public function httpResponseSendBefore($observer)
{
$response = $observer->getEvent()->getResponse();
if ($this->_getFpc()->isActive() && !$this->_cached && Mage::helper('fpc')->canCacheRequest() && $response->getHttpResponseCode() == 200) {
$fullActionName = Mage::helper('fpc')->getFullActionName();
$cacheableActions = Mage::helper('fpc')->getCacheableActions();
if (in_array($fullActionName, $cacheableActions)) {
$key = Mage::helper('fpc')->getKey();
$body = $observer->getEvent()->getResponse()->getBody();
$session = Mage::getSingleton('core/session');
$formKey = $session->getFormKey();
if ($formKey) {
$body = str_replace($formKey, self::FORM_KEY_PLACEHOLDER, $body);
$this->_placeholder[] = self::FORM_KEY_PLACEHOLDER;
$this->_html[] = $formKey;
}
$sid = $session->getEncryptedSessionId();
if ($sid) {
$body = str_replace($sid, self::SESSION_ID_PLACEHOLDER, $body);
$this->_placeholder[] = self::SESSION_ID_PLACEHOLDER;
$this->_html[] = $sid;
}
// edit cacheTags via event
$cacheTags = new Varien_Object();
$cacheTags->setValue($this->_cacheTags);
Mage::dispatchEvent('fpc_observer_collect_cache_tags', array('cache_tags' => $cacheTags));
$this->_cacheTags = $cacheTags->getValue();
$this->_getFpc()->save(time() . $body, $key, $this->_cacheTags);
$this->_cached = true;
$body = str_replace($this->_placeholder, $this->_html, $body);
$observer->getEvent()->getResponse()->setBody($body);
}
}
}
示例14: formatValue
/**
* Format total value based on order currency
*
* @param Varien_Object $total
* @return string
*/
public function formatValue($total)
{
if (!$total->getIsFormated()) {
return $this->getOrder()->formatPrice($total->getValue());
}
return $total->getValue();
}
示例15: _getAttributeValue
protected function _getAttributeValue($item, $attrCode, $mapItem)
{
//Callback method configuration for special attribute
Mage::app()->setCurrentStore($this->getProfile()->getStoreId());
$attributeValueFilter = array('price_catalog_rule' => '_getPriceWithCatalogRule', 'url' => '_getProductUrl', 'price' => '_getPrice', 'gross_price' => '_getGrossPrice', 'qty' => '_getQuantity', 'is_in_stock' => '_getIsInStock', 'image_url' => '_getImageUrl', '_category' => '_getProductCategory', '_category_id' => '_getProductCategoryId', '_categories' => '_getProductCategories', '_media_gallery' => '_getMediaGallery', 'base_price_reference_amount' => '_getBasePriceReferenceAmount', 'is_salable' => '_getIsSalable', 'google_mapping' => '_getGoogleMapping', 'manage_stock' => '_getManageStock', '_type' => '_getType');
$attrValue = $item->getData($attrCode);
if (empty($attrValue)) {
$item->load($item->getId());
$attrValue = $item->getData($attrCode);
}
if (isset($attributeValueFilter[$attrCode])) {
$attrValue = $this->{$attributeValueFilter}[$attrCode]($item, $mapItem);
}
if (isset($this->_attributeValues[$attrCode])) {
if (isset($this->_attributeValues[$attrCode][$attrValue])) {
$attrValue = $this->_attributeValues[$attrCode][$attrValue];
}
}
if (isset($this->_attributeTypes[$attrCode])) {
if ($this->_attributeTypes[$attrCode] == 'multiselect') {
$currentValues = explode(',', $attrValue);
foreach ($currentValues as &$currentValue) {
if (isset($this->_attributeValues[$attrCode][$currentValue])) {
$currentValue = $this->_attributeValues[$attrCode][$currentValue];
}
}
$attrValue = implode(',', $currentValues);
}
}
Mage::app()->setCurrentStore(0);
$eventObject = new Varien_Object(array('value' => $attrValue, 'attribute_code' => $attrCode, 'item' => $mapItem));
Mage::dispatchEvent('mep_product_attribute_value', array('export' => $eventObject));
return $eventObject->getValue();
}