本文整理汇总了PHP中Magento\Sales\Model\Order\Item::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::getId方法的具体用法?PHP Item::getId怎么用?PHP Item::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Sales\Model\Order\Item
的用法示例。
在下文中一共展示了Item::getId方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assertOrderItem
/**
* @param \Magento\Sales\Model\Order\Item $orderItem
* @param array $response
* @return void
*/
protected function assertOrderItem(\Magento\Sales\Model\Order\Item $orderItem, array $response)
{
$this->assertEquals($orderItem->getId(), $response['item_id']);
$this->assertEquals($orderItem->getOrderId(), $response['order_id']);
$this->assertEquals($orderItem->getProductId(), $response['product_id']);
$this->assertEquals($orderItem->getProductType(), $response['product_type']);
$this->assertEquals($orderItem->getBasePrice(), $response['base_price']);
$this->assertEquals($orderItem->getRowTotal(), $response['row_total']);
}
示例2: getOrderItemVariables
/**
* Retrieve tracking variables for an order item
*
* @param \Magento\Sales\Model\Order\Item $item The order item
*
* @return array
*/
private function getOrderItemVariables($item)
{
$variables = [];
if (!$item->isDummy()) {
$itemId = $item->getId();
$prefix = "order.items.{$itemId}";
$variables[$prefix . '.sku'] = $item->getSku();
$variables[$prefix . '.product_id'] = $item->getProductId();
$variables[$prefix . '.qty'] = $item->getQtyOrdered();
$variables[$prefix . '.price'] = $item->getBasePrice();
$variables[$prefix . '.row_total'] = $item->getRowTotal();
$variables[$prefix . '.label'] = $item->getName();
$variables[$prefix . '.salesrules'] = $item->getAppliedRuleIds();
if ($product = $item->getProduct()) {
$categoriesId = $product->getCategoryIds();
if (count($categoriesId)) {
$variables[$prefix . '.category_ids'] = implode(",", $categoriesId);
}
}
}
return $variables;
}
示例3: addItem
/**
* @param \Magento\Sales\Model\Order\Item $item
* @return $this
*/
public function addItem(\Magento\Sales\Model\Order\Item $item)
{
$item->setOrder($this);
if (!$item->getId()) {
$this->setItems(array_merge($this->getItems(), [$item]));
}
return $this;
}
示例4: initFromOrderItem
/**
* Initialize creation data from existing order Item
*
* @param \Magento\Sales\Model\Order\Item $orderItem
* @param int $qty
* @return \Magento\Quote\Model\Quote\Item|string|$this
*/
public function initFromOrderItem(\Magento\Sales\Model\Order\Item $orderItem, $qty = null)
{
if (!$orderItem->getId()) {
return $this;
}
$product = $this->_objectManager->create('Magento\\Catalog\\Model\\Product')->setStoreId($this->getSession()->getStoreId())->load($orderItem->getProductId());
if ($product->getId()) {
$product->setSkipCheckRequiredOption(true);
$buyRequest = $orderItem->getBuyRequest();
if (is_numeric($qty)) {
$buyRequest->setQty($qty);
}
$item = $this->getQuote()->addProduct($product, $buyRequest);
if (is_string($item)) {
return $item;
}
if ($additionalOptions = $orderItem->getProductOptionByCode('additional_options')) {
$item->addOption(new \Magento\Framework\DataObject(['product' => $item->getProduct(), 'code' => 'additional_options', 'value' => serialize($additionalOptions)]));
}
$this->_eventManager->dispatch('sales_convert_order_item_to_quote_item', ['order_item' => $orderItem, 'quote_item' => $item]);
return $item;
}
return $this;
}
示例5: addItem
/**
* @param \Magento\Sales\Model\Order\Item $item
* @return $this
*/
public function addItem(\Magento\Sales\Model\Order\Item $item)
{
$item->setOrder($this);
if (!$item->getId()) {
$this->getItemsCollection()->addItem($item);
}
return $this;
}
示例6: setOrderItem
/**
* Declare order item instance
*
* @param \Magento\Sales\Model\Order\Item $item
* @return $this
*/
public function setOrderItem(\Magento\Sales\Model\Order\Item $item)
{
$this->_orderItem = $item;
$this->setOrderItemId($item->getId());
return $this;
}
示例7: _canRefundNoDummyItem
/**
* Check if no dummy order item can be refunded
*
* @param \Magento\Sales\Model\Order\Item $item
* @param array $invoiceQtysRefundLimits
* @return bool
*/
protected function _canRefundNoDummyItem($item, $invoiceQtysRefundLimits = [])
{
if ($item->getQtyToRefund() < 0) {
return false;
}
if (isset($invoiceQtysRefundLimits[$item->getId()])) {
return $invoiceQtysRefundLimits[$item->getId()] > 0;
}
return true;
}
示例8: getCreditmemoData
/**
* @param \Magento\Sales\Model\Order\Item $orderItem
* @return array
*/
public function getCreditmemoData(\Magento\Sales\Model\Order\Item $orderItem)
{
$data = [$orderItem->getId() => $orderItem->getQtyToRefund()];
foreach ($this->observerManager->getObservers() as $observer) {
if (is_callable([$observer, 'getCreditmemoData'])) {
$params = new DataObject(['order_item' => $orderItem, 'credit_memo' => $data]);
$data = $observer->getCreditmemoData($params);
}
}
return $data;
}
示例9: getCreditmemoData
/**
* @param \Magento\Sales\Model\Order\Item $orderItem
* @return array
*/
public function getCreditmemoData(\Magento\Sales\Model\Order\Item $orderItem)
{
$data = [$orderItem->getId() => $orderItem->getQtyToRefund()];
return $data;
}
示例10: itemToQuoteItem
/**
* Retrieve
*
* @param \Magento\Sales\Model\Order\Item $item
* @return \Magento\Sales\Model\Quote\Item
*/
public function itemToQuoteItem(\Magento\Sales\Model\Order\Item $item)
{
$quoteItem = $this->_quoteItemFactory->create()->setStoreId($item->getOrder()->getStoreId())->setQuoteItemId($item->getId())->setProductId($item->getProductId())->setParentProductId($item->getParentProductId());
$this->_objectCopyService->copyFieldsetToTarget('sales_convert_order_item', 'to_quote_item', $item, $quoteItem);
return $quoteItem;
}