當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Observer::getProduct方法代碼示例

本文整理匯總了PHP中Magento\Framework\Event\Observer::getProduct方法的典型用法代碼示例。如果您正苦於以下問題:PHP Observer::getProduct方法的具體用法?PHP Observer::getProduct怎麽用?PHP Observer::getProduct使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\Event\Observer的用法示例。


在下文中一共展示了Observer::getProduct方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     // get the product object
     $_product = $observer->getProduct();
     // pass the SKU to Processwire
     $this->updateWireProduct($_product, 'On Save');
 }
開發者ID:the-big-surf,項目名稱:wire-products-hook,代碼行數:7,代碼來源:WireProductsSaveAfter.php

示例2: execute

 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $data = $this->_request->getParams();
     $product = $observer->getProduct();
     $billing = $data['product']['billing_options_table'];
     $model = $this->_attributeFactory->create();
     $attributeId = $product->getResource()->getAttribute('billing_options')->getAttributeId();
     $productId = $product->getId();
     /** @var \Magenest\Subscription\Model\Attribute $model */
     $modelCollection = $model->getCollection();
     $modelCollection->addFieldToFilter('attribute_id', $attributeId);
     $modelCollection->addFieldToFilter('entity_id', $productId);
     $object = $modelCollection->getFirstItem();
     if ($object->getId()) {
         $object->setValue($billing)->save();
     } else {
         $data = ['attribute_id' => $attributeId, 'entity_id' => $productId, 'value' => $billing];
         $model->setData($data)->save();
     }
 }
開發者ID:dragonsword007008,項目名稱:magento2,代碼行數:20,代碼來源:Save.php

示例3: execute

 /**
  * Event handler for the "catalog_product_save_after" and  event.
  * Sends a product update API call to Nosto.
  *
  * @param Observer $observer
  * @return void
  */
 public function execute(Observer $observer)
 {
     if ($this->_moduleManager->isEnabled('Nosto_Tagging')) {
         // Always "delete" the product for all stores it is available in.
         // This is done to avoid data inconsistencies as even if a product
         // is edited for only one store, the updated data can reflect in
         // other stores as well.
         /* @var \Magento\Catalog\Model\Product $product */
         /** @noinspection PhpUndefinedMethodInspection */
         $product = $observer->getProduct();
         foreach ($product->getStoreIds() as $storeId) {
             /** @var Store $store */
             $store = $this->_storeManager->getStore($storeId);
             /** @var \NostoAccount $account */
             $account = $this->_accountHelper->findAccount($store);
             if ($account === null) {
                 continue;
             }
             if (!$this->validateProduct($product)) {
                 continue;
             }
             // Load the product model for this particular store view.
             /** @var \NostoProduct $model */
             $metaProduct = $this->_productBuilder->build($product, $store);
             if (is_null($metaProduct)) {
                 continue;
             }
             try {
                 $op = new \NostoServiceProduct($account);
                 $op->addProduct($metaProduct);
                 $this->doRequest($op);
             } catch (\NostoException $e) {
                 $this->_logger->error($e, ['exception' => $e]);
             }
         }
     }
 }
開發者ID:Nosto,項目名稱:nosto-magento2,代碼行數:44,代碼來源:Base.php


注:本文中的Magento\Framework\Event\Observer::getProduct方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。