本文整理汇总了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');
}
示例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();
}
}
示例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]);
}
}
}
}