本文整理汇总了PHP中Varien_Event_Observer::getProduct方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Event_Observer::getProduct方法的具体用法?PHP Varien_Event_Observer::getProduct怎么用?PHP Varien_Event_Observer::getProduct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Event_Observer
的用法示例。
在下文中一共展示了Varien_Event_Observer::getProduct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: catalogProductPrepareSave
public function catalogProductPrepareSave(Varien_Event_Observer $observer)
{
if ($observer->getRequest()->getModuleName() == 'ampgrid') {
$date = $observer->getProduct()->getData('created_at');
$observer->getProduct()->setData('created_at', strtotime($date));
}
}
示例2: salesQuoteItemSetCustomAttribute
public function salesQuoteItemSetCustomAttribute(Varien_Event_Observer $observer)
{
$item = $observer->getQuoteItem();
$product = $observer->getProduct();
$categories = $observer->getProduct()->getCategoryIds();
//$item = Mage::getSingleton('checkout/session')->getQuote()->getItemByProduct($product);
$price = $observer->getEvent()->getQuoteItem()->getPrice();
$name = $observer->getEvent()->getQuoteItem()->getName();
$qty = $observer->getEvent()->getQuoteItem()->getQty();
$id = $observer->getEvent()->getQuoteItem()->getProductId();
$sku = $observer->getEvent()->getQuoteItem()->getSku();
$pid = Mage::getModel('catalog/product')->getResource()->getIdBySku($sku);
$foundProduct = Mage::getModel('catalog/product')->load($pid);
$price = $foundProduct->getPrice();
$specialprice = $foundProduct->getSpecialPrice();
$total_amount_setting = Mage::getStoreConfig('payumoneycharge/payumoneycharge_group/freeshippingtotal');
$total_minimum_setting = Mage::getStoreConfig('payumoneycharge/payumoneycharge_group/minimumshippingamount');
$total_each_setting = Mage::getStoreConfig('payumoneycharge/payumoneycharge_group/shipamounteach');
/*if(in_array(165,$categories) || in_array(141,$categories))
{
$product = Mage::getSingleton('catalog/product')->load($id);
$moq = $product->getMinqtyforfreeshipping();
$shippingcost = $product->getShippingcost();
$extraShippingCost = $moq - $qty * $shippingcost;
$item->setExtraShipping($extraShippingCost);
Mage::log("Bulk Shipping Charges:".$extraShippingCost);
}
else */
if (in_array(154, $categories) || in_array(155, $categories) || in_array(156, $categories) || in_array(160, $categories) || in_array(163, $categories) || in_array(182, $categories) || in_array(188, $categories) || in_array(189, $categories) || in_array(180, $categories) || in_array(215, $categories)) {
$product = Mage::getSingleton('catalog/product')->load($id);
$shippingcost = $product->getShippingcost();
$extraShippingCost = 0;
$item->setExtraShipping($extraShippingCost);
Mage::log("Civil Shipping Charges:" . $extraShippingCost);
} else {
if ($specialprice) {
$row_total = $specialprice * $qty;
} else {
$row_total = $price * $qty;
}
if ($row_total >= 200) {
if ($specialprice) {
$cartGrossTotal = $specialprice * $qty;
} else {
$cartGrossTotal = $price * $qty;
}
$grand = $cartGrossTotal;
$gtotal = (int) $grand / 100;
$noofhun = (int) $gtotal - 1;
$timesofhun = $total_minimum_setting + $noofhun * $total_each_setting;
} else {
$timesofhun = $total_minimum_setting;
}
$item->setShippingCost($timesofhun);
Mage::log("Non Bulk Shipping Charges:" . $timesofhun);
//Mage::log("Product Id:".$name);
//Mage::log("Product Id:".$id);
}
}
示例3: removeMaintenanceFromGetQuantity
/**
* Observer on payperrentals/inventory getquantity that removes quantity in maintenance from available quantity
* We check both the quantity in the product EAV field maintenance_quantity and also
* quantity that is under maintenance in a maintenance report when not using specific dates
*
* @param Varien_Event_Observer $observer
*/
function removeMaintenanceFromGetQuantity(Varien_Event_Observer $observer)
{
$maintenanceQuantity = Mage::getResourceModel('catalog/product')->getAttributeRawValue($observer->getProduct(), 'maintenance_quantity', Mage::app()->getStore()->getStoreId());
$maintenanceQuantityReports = Mage::helper('simaintenance')->getReportMaintenanceQuantity($observer->getProduct());
$retQty = $observer->getResult()->getRetQty();
$retQty = $retQty - ($maintenanceQuantity + $maintenanceQuantityReports);
$observer->getResult()->setRetQty($retQty);
}
示例4: virtualZeroQty
public function virtualZeroQty(Varien_Event_Observer $observer)
{
// the purpose is to set flag VirtualZeroQty to true if quantity less or equal 0 (and then use this flag in the templates), by the client request in the #2014032010000224 ticket
if ($observer->getProduct() && $observer->getProduct()->getTypeId() == 'virtual') {
$_product = Mage::registry('product');
if ($_product && $_product->getStockItem()->getManageStock() == 1 && $_product->getStockItem()->getQty() <= 0) {
$observer->getProduct()->setVirtualZeroQty(true);
}
}
}
示例5: deleteImagesFromCloudinary
public function deleteImagesFromCloudinary(Varien_Event_Observer $event)
{
$cloudinaryImage = Mage::getModel('cloudinary_cloudinary/image');
foreach ($this->_getImagesToDelete($event->getProduct()) as $image) {
$cloudinaryImage->deleteImage($image['file']);
}
}
示例6: reverseLink
/**
* Creates two-way linking of related products after a product save, if
* link data is available.
*
* @param Varien_Event_Observer $observer
*
* @return void
*/
public function reverseLink($observer)
{
if (!Mage::helper('twowaylink')->isEnabled()) {
return;
}
$product = $observer->getProduct();
if (!$product) {
return;
}
// Grab related product link data
$relatedLinkData = $product->getRelatedLinkData();
$relatedLinkData[$product->getId()] = array('position' => null);
// Add back removed IDs so they can be removed in the loop
if (!is_null($this->_idsToRemove) && !empty($this->_idsToRemove)) {
$relatedLinkData += $this->_idsToRemove;
}
$relatedLinkData2 = $relatedLinkData;
if (!empty($relatedLinkData)) {
// For each of the products being assigned to $product, associate
// each of the products to another (every possible combination).
// Remove if it's appropriate.
foreach ($relatedLinkData as $id => $position) {
foreach ($relatedLinkData2 as $id2 => $position2) {
if ($id === $id2) {
continue;
}
if (isset($this->_idsToRemove[$id]) || isset($this->_idsToRemove[$id2])) {
Mage::getSingleton('twowaylink/link_api')->removeLink($id, $id2, Mage_Catalog_Model_Product_Link::LINK_TYPE_RELATED);
} else {
Mage::getSingleton('twowaylink/link_api')->createLink($id, $id2, Mage_Catalog_Model_Product_Link::LINK_TYPE_RELATED);
}
}
}
}
}
示例7: handleMultipleQuantitiesPost
/**
* event: catalog_product_save_before
*
* @param Varien_Event_Observer $observer
*/
public function handleMultipleQuantitiesPost(Varien_Event_Observer $observer)
{
if (!Mage::app()->getRequest()->isPost()) {
return;
}
if (!isset($post['wgmulti_original_use_multiple_qty']) && !isset($post['wgmulti_use_multiple_qty'])) {
return;
}
/** @var Mage_Catalog_Model_Product $product */
$product = $observer->getProduct();
$post = Mage::app()->getRequest()->getPost();
// if multiple quantity was disabled
if ($post['wgmulti_original_use_multiple_qty'] == 1 && $post['wgmulti_use_multiple_qty'] == 0) {
Mage::getModel('wgmulti/warehouse_product')->getCollection()->addProductIdFilter($product->getId())->delete();
}
// if multiple quantity was enabled
if ($post['wgmulti_use_multiple_qty'] == 1) {
$totalQty = 0.0;
foreach ($post['wgmultiqty'] as $warehouseId => $qty) {
Mage::getModel('wgmulti/warehouse_product')->getCollection()->addWarehouseIdFilter($warehouseId)->addProductIdFilter($product->getId())->getFirstItem()->setWarehouseId($warehouseId)->setProductId($product->getId())->setQty($qty)->save();
$totalQty += $qty;
}
$product->getStockItem()->setQty($totalQty);
}
}
示例8: addedItemQtyValidate
public function addedItemQtyValidate(Varien_Event_Observer $observer)
{
if (!Mage::helper('aitunits')->getAvailableStores()) {
return false;
}
/* {#AITOC_COMMENT_END#}
$performer = Aitoc_Aitsys_Abstract_Service::get()->platform()->getModule('Aitoc_Aitunits')->getLicense()->getPerformer();
$ruler = $performer->getRuler();
$groupId = Mage::app()->getGroup()->getId();
if(!in_array($groupId, $ruler->getAvailableStores()))
{
return false;
}
{#AITOC_COMMENT_START#} */
$item = $observer->getProduct();
$item = Mage::helper('aitunits')->getValidProduct($item);
$params = Mage::app()->getRequest()->getParams();
$itemType = $item->getTypeId();
switch ($itemType) {
case 'grouped':
$products = $item->getTypeInstance(true)->getAssociatedProducts($item);
$aProductQtys = $params['super_group'];
foreach ($products as $product) {
$productQty = $aProductQtys[$product->getId()];
$this->_validateProduct($product, $productQty);
}
return;
case 'simple' || 'virtual' || 'configurable':
$itemQty = $params['qty'];
$this->_validateProduct($item, $itemQty);
return;
}
}
示例9: catalogProductSaveCommitAfter
/**
* Clear the category list block for this product
*
* @param Varien_Event_Observer $args
*/
public function catalogProductSaveCommitAfter(Varien_Event_Observer $args)
{
$product = $args->getProduct();
if ($product->getId()) {
$tag = Mage_Catalog_Model_Product::CACHE_TAG . '_' . $product->getId();
Mage::app()->cleanCache(array($tag));
}
}
示例10: addToCartComplete
public function addToCartComplete(Varien_Event_Observer $observer)
{
if ($observer->getRequest()->getParam('return_url') || !Mage::getStoreConfig('suggestpage/general/show_after_addtocart')) {
return;
}
if ($this->_isMobile() && !Mage::getStoreConfig('suggestpage/mobile/show_after_addtocart')) {
return;
}
$observer->getResponse()->setRedirect(Mage::getUrl('suggest'));
$session = Mage::getSingleton('checkout/session');
$session->setNoCartRedirect(true);
$session->setSuggestpageProductId($observer->getProduct()->getId());
$session->setViewCartUrl(Mage::getUrl('suggest'));
//ajaxpro integration
$message = Mage::helper('checkout')->__('%s was added to your shopping cart.', Mage::helper('core')->htmlEscape($observer->getProduct()->getName()));
$session->addSuccess($message);
}
示例11: catalogProductSaveBefore
public function catalogProductSaveBefore(Varien_Event_Observer $observer)
{
/** @var Mage_Catalog_Model_Product $product */
$product = $observer->getProduct();
$attributeSetId = $product->getAttributeSetId();
$product->setAttributeSetFilter($attributeSetId);
return $this;
}
示例12: addDefaultDdqValues
/**
* Add default ddq data to loaded product record.
*
* @param Varien_Event_Observer $observer
*/
public function addDefaultDdqValues(Varien_Event_Observer $observer)
{
if ($this->_getHelper()->isEnabled()) {
// we need to assign this to a variable in order to pass it as a reference to assignDefaultProductData
$product = $observer->getProduct();
$this->_getHelper()->assignDefaultProductData($product);
}
}
示例13: productAfterLoad
public function productAfterLoad(Varien_Event_Observer $observer)
{
/**
* @var Mage_Catalog_Model_Product | null
*/
$product = $observer->getProduct();
$product->setName($product->getName() . " - fcku yeah!!!");
}
示例14: productAddUpdate
/**
* When added/update a product
* @param Varien_Event_Observer $observer
*/
public function productAddUpdate($observer)
{
if ($this->autoIndex) {
$product = $observer->getProduct();
$store_id = Mage::app()->getRequest()->getParam('store');
$this->updateSolrIndex($product->getId(), $store_id);
}
}
示例15: catalogProductLoadAfter
/**
* "Unload" a loaded product if the customer is not allowed to view it
*
* @param Varien_Event_Observer $observer
* @return void
*/
public function catalogProductLoadAfter(Varien_Event_Observer $observer)
{
$product = $observer->getProduct();
$this->_applyGroupsCatalogSettingsToEntity($product);
if ($product->getData('forbidden_by_groupscatalog2')) {
$this->_applyHiddenEntityHandling(Mage_Catalog_Model_Product::ENTITY);
}
}