本文整理匯總了PHP中Varien_Event_Observer::getSource方法的典型用法代碼示例。如果您正苦於以下問題:PHP Varien_Event_Observer::getSource方法的具體用法?PHP Varien_Event_Observer::getSource怎麽用?PHP Varien_Event_Observer::getSource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Varien_Event_Observer
的用法示例。
在下文中一共展示了Varien_Event_Observer::getSource方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: observe
/**
* @param Varien_Event_Observer $observer
* @event sales_quote_merge_before
*/
public function observe(Varien_Event_Observer $observer)
{
/** @var Aleron75_UnmergedCart_Helper_Data $h */
$h = Mage::helper('aleron75_unmergedcart');
if (!$h->isActive()) {
return;
}
/** @var Mage_Sales_Model_Quote $customerQuote */
$customerQuote = $observer->getQuote();
/** @var Mage_Sales_Model_Quote $sessionQuote */
$sessionQuote = $observer->getSource();
if ($customerQuote->getId() && $sessionQuote->getId() != $customerQuote->getId()) {
/** @var Mage_Sales_Model_Quote $discardableQuote */
$discardableQuote = $h->isKeepSessionCart() ? $customerQuote : $sessionQuote;
/** @var Mage_Sales_Model_Quote_Item $item */
foreach ($discardableQuote->getAllItems() as $item) {
$item->isDeleted(true);
if ($item->getHasChildren()) {
/** @var Mage_Sales_Model_Quote_Item_Abstract $child */
foreach ($item->getChildren() as $child) {
$child->isDeleted(true);
}
}
}
}
}
示例2: truncateCustomerCart
/**
* Truncate the customer's cart if active
* @access public
* @return void
*/
public function truncateCustomerCart(Varien_Event_Observer $observer)
{
if (Mage::helper('jbh_cartmerge')->isActive()) {
if ($observer->getSource()->hasItems() || Mage::helper('jbh_cartmerge')->cleanIfEmpty()) {
if (is_object($observer->getQuote()) && $observer->getQuote()->getId()) {
$observer->getQuote()->removeAllItems();
}
}
}
}
示例3: salesQuoteMergeBefore
/**
* Remove products that are in the cart that where not hidden while logged out
* but are hidden to the customer once logged in.
*
* @param Varien_Event_Observer $observer
*/
public function salesQuoteMergeBefore(Varien_Event_Observer $observer)
{
/** @var Mage_Sales_Model_Quote $guestQuote */
$guestQuote = $observer->getSource();
// If a hidden product is loaded, it's entity_id is set to null.
// So all we need to do here is set the deleted property to true,
// and then they will not be merged into the customer quote.
foreach ($guestQuote->getItemsCollection() as $quoteItem) {
if (!$quoteItem->getProductId()) {
$quoteItem->isDeleted(true);
}
}
}