当前位置: 首页>>代码示例>>PHP>>正文


PHP Object::getProductId方法代码示例

本文整理汇总了PHP中Magento\Framework\Object::getProductId方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::getProductId方法的具体用法?PHP Object::getProductId怎么用?PHP Object::getProductId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Object的用法示例。


在下文中一共展示了Object::getProductId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validate

 /**
  * Validate Product Rule Condition
  *
  * @param \Magento\Framework\Object $object
  * @return bool
  */
 public function validate(\Magento\Framework\Object $object)
 {
     //@todo reimplement this method when is fixed MAGETWO-5713
     /** @var \Magento\Catalog\Model\Product $product */
     $product = $object->getProduct();
     if (!$product instanceof \Magento\Catalog\Model\Product) {
         $product = $this->_productFactory->create()->load($object->getProductId());
     }
     $product->setQuoteItemQty($object->getQty())->setQuoteItemPrice($object->getPrice())->setQuoteItemRowTotal($object->getBaseRowTotal());
     return parent::validate($product);
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:17,代码来源:Product.php

示例2: getIdentifierId

 /**
  * Retrieve identifier of block item
  *
  * @param \Magento\Framework\Object $item
  * @return int
  */
 public function getIdentifierId($item)
 {
     return $item->getProductId();
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:10,代码来源:AbstractSidebar.php

示例3: renderConfigureResult

 /**
  * Prepares and render result of composite product configuration request
  *
  * The $configureResult variable holds either:
  *  - 'ok' = true, and 'product_id', 'buy_request', 'current_store_id', 'current_customer_id'
  *  - 'error' = true, and 'message' to show
  *
  * @param \Magento\Framework\Object $configureResult
  * @return \Magento\Framework\View\Result\Layout
  */
 public function renderConfigureResult(\Magento\Framework\Object $configureResult)
 {
     try {
         if (!$configureResult->getOk()) {
             throw new \Magento\Framework\Exception\LocalizedException(__($configureResult->getMessage()));
         }
         $currentStoreId = (int) $configureResult->getCurrentStoreId();
         if (!$currentStoreId) {
             $currentStoreId = $this->_storeManager->getStore()->getId();
         }
         $product = $this->productRepository->getById($configureResult->getProductId(), false, $currentStoreId);
         $this->_coreRegistry->register('current_product', $product);
         $this->_coreRegistry->register('product', $product);
         // Register customer we're working with
         $customerId = (int) $configureResult->getCurrentCustomerId();
         $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customerId);
         // Prepare buy request values
         $buyRequest = $configureResult->getBuyRequest();
         if ($buyRequest) {
             $this->_catalogProduct->prepareProductOptions($product, $buyRequest);
         }
         $isOk = true;
         $productType = $product->getTypeId();
     } catch (\Exception $e) {
         $isOk = false;
         $productType = null;
         $this->_coreRegistry->register('composite_configure_result_error_message', $e->getMessage());
     }
     return $this->_initConfigureResultLayout($isOk, $productType);
 }
开发者ID:nja78,项目名称:magento2,代码行数:40,代码来源:Composite.php

示例4: registerItemSale

 /**
  * Subtract ordered qty for product
  *
  * @param  \Magento\Framework\Object $item
  * @return $this
  * @throws \Magento\Framework\Model\Exception
  */
 public function registerItemSale(\Magento\Framework\Object $item)
 {
     $productId = $item->getProductId();
     if (!$productId) {
         throw new \Magento\Framework\Model\Exception(__('We cannot specify a product identifier for the order item.'));
     }
     /** @var Item $stockItem */
     $stockItem = $this->_stockItemFactory->create()->loadByProduct($productId);
     if ($this->stockItemService->isQty($this->getProductType($productId))) {
         if ($item->getStoreId()) {
             $stockItem->setStoreId($item->getStoreId());
         }
         if ($stockItem->checkQty($item->getQtyOrdered())) {
             $stockItem->subtractQty($item->getQtyOrdered());
             $stockItem->save();
         }
     }
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:26,代码来源:Stock.php

示例5: isMessagesAvailable

 /**
  * Check availability of giftmessages for specified entity.
  *
  * @param string $type
  * @param \Magento\Framework\Object $entity
  * @param \Magento\Store\Model\Store|int|null $store
  * @return bool|string|null
  */
 public function isMessagesAvailable($type, \Magento\Framework\Object $entity, $store = null)
 {
     if ($type == 'items') {
         $items = $entity->getAllItems();
         if (!is_array($items) || empty($items)) {
             return $this->_scopeConfig->getValue(self::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ITEMS, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store);
         }
         if ($entity instanceof \Magento\Sales\Model\Quote) {
             $_type = $entity->getIsMultiShipping() ? 'address_item' : 'item';
         } else {
             $_type = 'order_item';
         }
         foreach ($items as $item) {
             if ($item->getParentItem()) {
                 continue;
             }
             if ($this->isMessagesAvailable($_type, $item, $store)) {
                 return true;
             }
         }
     } elseif ($type == 'item') {
         return $this->_getDependenceFromStoreConfig($entity->getProduct()->getGiftMessageAvailable(), $store);
     } elseif ($type == 'order_item') {
         return $this->_getDependenceFromStoreConfig($entity->getGiftMessageAvailable(), $store);
     } elseif ($type == 'address_item') {
         $storeId = is_numeric($store) ? $store : $this->_storeManager->getStore($store)->getId();
         if (!$this->isCached('address_item_' . $entity->getProductId())) {
             $this->setCached('address_item_' . $entity->getProductId(), $this->_productFactory->create()->setStoreId($storeId)->load($entity->getProductId())->getGiftMessageAvailable());
         }
         return $this->_getDependenceFromStoreConfig($this->getCached('address_item_' . $entity->getProductId()), $store);
     } else {
         return $this->_scopeConfig->getValue(self::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ORDER, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store);
     }
     return false;
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:43,代码来源:Message.php

示例6: getRowUrl

 /**
  * @param \Magento\Framework\Object $row
  *
  * @return string
  */
 public function getRowUrl($row)
 {
     return $this->getUrl('catalog/product/edit', ['id' => $row->getProductId()]);
 }
开发者ID:nja78,项目名称:magento2,代码行数:9,代码来源:Grid.php

示例7: renderConfigureResult

 /**
  * Prepares and render result of composite product configuration request
  *
  * The $configureResult variable holds either:
  *  - 'ok' = true, and 'product_id', 'buy_request', 'current_store_id', 'current_customer_id'
  *  - 'error' = true, and 'message' to show
  *
  * @param \Magento\Framework\Object $configureResult
  * @return void
  */
 public function renderConfigureResult(\Magento\Framework\Object $configureResult)
 {
     try {
         if (!$configureResult->getOk()) {
             throw new \Magento\Framework\Model\Exception($configureResult->getMessage());
         }
         $currentStoreId = (int) $configureResult->getCurrentStoreId();
         if (!$currentStoreId) {
             $currentStoreId = $this->_storeManager->getStore()->getId();
         }
         $product = $this->_productFactory->create()->setStoreId($currentStoreId)->load($configureResult->getProductId());
         if (!$product->getId()) {
             throw new \Magento\Framework\Model\Exception(__('The product is not loaded.'));
         }
         $this->_coreRegistry->register('current_product', $product);
         $this->_coreRegistry->register('product', $product);
         // Register customer we're working with
         $customerId = (int) $configureResult->getCurrentCustomerId();
         // TODO: Remove the customer model from the registry once all readers are refactored
         $customerModel = $this->_converter->loadCustomerModel($customerId);
         $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER, $customerModel);
         $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customerId);
         // Prepare buy request values
         $buyRequest = $configureResult->getBuyRequest();
         if ($buyRequest) {
             $this->_catalogProduct->prepareProductOptions($product, $buyRequest);
         }
         $isOk = true;
         $productType = $product->getTypeId();
     } catch (\Exception $e) {
         $isOk = false;
         $productType = null;
         $this->_coreRegistry->register('composite_configure_result_error_message', $e->getMessage());
     }
     $this->_initConfigureResultLayout($isOk, $productType);
     $this->_view->renderLayout();
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:47,代码来源:Composite.php


注:本文中的Magento\Framework\Object::getProductId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。