当前位置: 首页>>代码示例>>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;未经允许,请勿转载。