本文整理汇总了PHP中Magento\Sales\Model\Order\Item类的典型用法代码示例。如果您正苦于以下问题:PHP Item类的具体用法?PHP Item怎么用?PHP Item使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Item类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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']);
}
开发者ID:whoople,项目名称:magento2-testing,代码行数:14,代码来源:OrderItemGetListTest.php
示例2: aroundGetProductId
/**
* Get product id
*
* @param \Magento\Sales\Model\Order\Admin\Item $subject
* @param callable $proceed
* @param \Magento\Sales\Model\Order\Item $item
*
* @return int
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundGetProductId(\Magento\Sales\Model\Order\Admin\Item $subject, \Closure $proceed, \Magento\Sales\Model\Order\Item $item)
{
if ($item->getProductType() == \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) {
$productOptions = $item->getProductOptions();
$product = $this->productFactory->create();
return $product->getIdBySku($productOptions['simple_sku']);
}
return $proceed($item);
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:19,代码来源:Configurable.php
示例3: assertOrderItem
/**
* @param \Magento\Sales\Model\Order\Item $orderItem
* @param array $response
* @return void
*/
protected function assertOrderItem(\Magento\Sales\Model\Order\Item $orderItem, array $response)
{
$expected = $orderItem->getBuyRequest()->getLinks();
$this->assertArrayHasKey('product_option', $response);
$this->assertArrayHasKey('extension_attributes', $response['product_option']);
$this->assertArrayHasKey('downloadable_option', $response['product_option']['extension_attributes']);
$actualOptions = $response['product_option']['extension_attributes']['downloadable_option'];
$this->assertArrayHasKey('downloadable_links', $actualOptions);
$this->assertEquals($expected, $actualOptions['downloadable_links']);
}
开发者ID:whoople,项目名称:magento2-testing,代码行数:15,代码来源:OrderItemRepositoryTest.php
示例4: assertOrderItem
/**
* @param \Magento\Sales\Model\Order\Item $orderItem
* @param array $response
* @return void
*/
protected function assertOrderItem(\Magento\Sales\Model\Order\Item $orderItem, array $response)
{
$expected = $orderItem->getBuyRequest()->getSuperAttribute();
$this->assertArrayHasKey('product_option', $response);
$this->assertArrayHasKey('extension_attributes', $response['product_option']);
$this->assertArrayHasKey('configurable_item_options', $response['product_option']['extension_attributes']);
$actualOptions = $response['product_option']['extension_attributes']['configurable_item_options'];
$this->assertTrue(is_array($actualOptions));
$this->assertTrue(is_array($actualOptions[0]));
$this->assertArrayHasKey('option_id', $actualOptions[0]);
$this->assertArrayHasKey('option_value', $actualOptions[0]);
$this->assertEquals(key($expected), $actualOptions[0]['option_id']);
$this->assertEquals(current($expected), $actualOptions[0]['option_value']);
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:19,代码来源:OrderItemRepositoryTest.php
示例5: assertOrderItem
/**
* @param \Magento\Sales\Model\Order\Item $orderItem
* @param array $response
* @return void
*/
protected function assertOrderItem(\Magento\Sales\Model\Order\Item $orderItem, array $response)
{
$bundleOption = $orderItem->getBuyRequest()->getBundleOption();
$bundleOptionQty = $orderItem->getBuyRequest()->getBundleOptionQty();
$this->assertArrayHasKey('product_option', $response);
$this->assertArrayHasKey('extension_attributes', $response['product_option']);
$this->assertArrayHasKey('bundle_options', $response['product_option']['extension_attributes']);
$actualOptions = $response['product_option']['extension_attributes']['bundle_options'];
$this->assertEquals(array_keys($bundleOption), array_column($actualOptions, 'option_id'));
$this->assertEquals($bundleOptionQty, array_column($actualOptions, 'option_qty', 'option_id'));
foreach ($actualOptions as $option) {
$expectedSelections = is_array($bundleOption[$option['option_id']]) ? $bundleOption[$option['option_id']] : [$bundleOption[$option['option_id']]];
$this->assertEquals($expectedSelections, $option['option_selections']);
}
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:20,代码来源:OrderItemRepositoryTest.php
示例6: assertOrderItem
/**
* @param \Magento\Sales\Model\Order\Item $orderItem
* @param array $response
* @return void
*/
protected function assertOrderItem(\Magento\Sales\Model\Order\Item $orderItem, array $response)
{
$expected = $orderItem->getBuyRequest()->getOptions();
$this->assertArrayHasKey('product_option', $response);
$this->assertArrayHasKey('extension_attributes', $response['product_option']);
$this->assertArrayHasKey('custom_options', $response['product_option']['extension_attributes']);
$actualOptions = $response['product_option']['extension_attributes']['custom_options'];
$expectedOptions = [];
foreach ($expected as $optionId => $optionValue) {
if (is_array($optionValue)) {
$optionValue = implode(',', $optionValue);
}
$expectedOptions[] = ['option_id' => $optionId, 'option_value' => $optionValue];
}
$this->assertEquals($expectedOptions, $actualOptions);
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:21,代码来源:OrderItemRepositoryTest.php
示例7: testSave
public function testSave()
{
$this->orderMock->expects($this->exactly(3))->method('getId')->willReturn(null);
$this->orderItemMock->expects($this->once())->method('getChildrenItems')->willReturn([]);
$this->orderItemMock->expects($this->once())->method('getQuoteParentItemId')->willReturn(null);
$this->orderMock->expects($this->once())->method('setTotalItemCount')->with(1);
$this->storeGroupMock->expects($this->once())->method('getDefaultStoreId')->willReturn(1);
$this->orderMock->expects($this->once())->method('getAllItems')->willReturn([$this->orderItemMock]);
$this->orderMock->expects($this->once())->method('validateBeforeSave')->willReturnSelf();
$this->orderMock->expects($this->once())->method('beforeSave')->willReturnSelf();
$this->orderMock->expects($this->once())->method('isSaveAllowed')->willReturn(true);
$this->orderMock->expects($this->once())->method('getEntityType')->willReturn('order');
$this->orderMock->expects($this->exactly(2))->method('getStore')->willReturn($this->storeMock);
$this->storeMock->expects($this->exactly(2))->method('getGroup')->willReturn($this->storeGroupMock);
$this->storeMock->expects($this->once())->method('getWebsite')->willReturn($this->websiteMock);
$this->storeGroupMock->expects($this->once())->method('getDefaultStoreId')->willReturn(1);
$this->salesSequenceManagerMock->expects($this->once())->method('getSequence')->with('order', 1)->willReturn($this->salesSequenceMock);
$this->salesSequenceMock->expects($this->once())->method('getNextValue')->willReturn('10000001');
$this->orderMock->expects($this->once())->method('setIncrementId')->with('10000001')->willReturnSelf();
$this->orderMock->expects($this->once())->method('getIncrementId')->willReturn(null);
$this->orderMock->expects($this->once())->method('getData')->willReturn(['increment_id' => '10000001']);
$this->objectRelationProcessorMock->expects($this->once())->method('validateDataIntegrity')->with(null, ['increment_id' => '10000001']);
$this->relationCompositeMock->expects($this->once())->method('processRelations')->with($this->orderMock);
$this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->adapterMock);
$this->adapterMock->expects($this->any())->method('quoteInto');
$this->adapterMock->expects($this->any())->method('describeTable')->will($this->returnValue([]));
$this->adapterMock->expects($this->any())->method('update');
$this->adapterMock->expects($this->any())->method('lastInsertId');
$this->orderMock->expects($this->any())->method('getId')->will($this->returnValue(1));
$this->entitySnapshotMock->expects($this->once())->method('isModified')->with($this->orderMock)->will($this->returnValue(true));
$this->resource->save($this->orderMock);
}
开发者ID:nja78,项目名称:magento2,代码行数:32,代码来源:OrderTest.php
示例8: testGetOriginalPrice
public function testGetOriginalPrice()
{
$price = 9.99;
$this->model->setPrice($price);
$this->assertEquals($price, $this->model->getOriginalPrice());
$originalPrice = 5.55;
$this->model->setData(\Magento\Sales\Api\Data\OrderItemInterface::ORIGINAL_PRICE, $originalPrice);
$this->assertEquals($originalPrice, $this->model->getOriginalPrice());
}
开发者ID:tingyeeh,项目名称:magento2,代码行数:9,代码来源:ItemTest.php
示例9: testCollect
public function testCollect()
{
$this->creditmemoMock->expects($this->once())->method('getAllItems')->willReturn([$this->creditmemoItemMock]);
$this->creditmemoItemMock->expects($this->atLeastOnce())->method('getOrderItem')->willReturn($this->orderItemMock);
$this->orderItemMock->expects($this->once())->method('isDummy')->willReturn(false);
$this->creditmemoItemMock->expects($this->once())->method('calcRowTotal')->willReturnSelf();
$this->creditmemoItemMock->expects($this->once())->method('getRowTotal')->willReturn(1);
$this->creditmemoItemMock->expects($this->once())->method('getBaseRowTotal')->willReturn(1);
$this->creditmemoItemMock->expects($this->once())->method('getRowTotalInclTax')->willReturn(1);
$this->creditmemoItemMock->expects($this->once())->method('getBaseRowTotalInclTax')->willReturn(1);
$this->creditmemoMock->expects($this->once())->method('setSubtotal')->with(1)->willReturnSelf();
$this->creditmemoMock->expects($this->once())->method('setBaseSubtotal')->with(1)->willReturnSelf();
$this->creditmemoMock->expects($this->once())->method('setSubtotalInclTax')->with(1)->willReturnSelf();
$this->creditmemoMock->expects($this->once())->method('setBaseSubtotalInclTax')->with(1)->willReturnSelf();
$this->creditmemoMock->expects($this->once())->method('getGrandTotal')->willReturn(1);
$this->creditmemoMock->expects($this->once())->method('setGrandTotal')->with(2)->willReturnSelf();
$this->creditmemoMock->expects($this->once())->method('getBaseGrandTotal')->willReturn(1);
$this->creditmemoMock->expects($this->once())->method('setBaseGrandTotal')->with(2)->willReturnSelf();
$this->assertEquals($this->total, $this->total->collect($this->creditmemoMock));
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:20,代码来源:SubtotalTest.php
示例10: testProcessRelation
public function testProcessRelation()
{
$this->addressHandlerMock->expects($this->once())->method('removeEmptyAddresses')->with($this->orderMock)->willReturnSelf();
$this->addressHandlerMock->expects($this->once())->method('process')->with($this->orderMock)->willReturnSelf();
$this->orderMock->expects($this->exactly(2))->method('getItems')->willReturn([$this->orderItemMock]);
$this->orderMock->expects($this->exactly(3))->method('getId')->willReturn('order-id-value');
$this->orderItemMock->expects($this->once())->method('setOrderId')->with('order-id-value')->willReturnSelf();
$this->orderItemMock->expects($this->once())->method('setOrder')->with($this->orderMock)->willReturnSelf();
$this->orderItemRepositoryMock->expects($this->once())->method('save')->with($this->orderItemMock)->willReturnSelf();
$this->orderMock->expects($this->exactly(2))->method('getPayment')->willReturn($this->orderPaymentMock);
$this->orderPaymentMock->expects($this->once())->method('setParentId')->with('order-id-value')->willReturnSelf();
$this->orderPaymentMock->expects($this->once())->method('setOrder')->with($this->orderMock)->willReturnSelf();
$this->orderPaymentResourceMock->expects($this->once())->method('save')->with($this->orderPaymentMock)->willReturnSelf();
$this->orderMock->expects($this->exactly(2))->method('getStatusHistories')->willReturn([$this->orderStatusHistoryMock]);
$this->orderStatusHistoryMock->expects($this->once())->method('setParentId')->with('order-id-value')->willReturnSelf();
$this->orderStatusHistoryMock->expects($this->once())->method('setOrder')->with($this->orderMock)->willReturnSelf();
$this->statusHistoryResource->expects($this->once())->method('save')->with($this->orderStatusHistoryMock)->willReturnSelf();
$this->orderMock->expects($this->exactly(2))->method('getRelatedObjects')->willReturn([$this->orderInvoiceMock]);
$this->orderInvoiceMock->expects($this->once())->method('setOrder')->with($this->orderMock)->willReturnSelf();
$this->orderInvoiceMock->expects($this->once())->method('save')->willReturnSelf();
$this->relationProcessor->processRelation($this->orderMock);
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:22,代码来源:RelationTest.php
示例11: 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;
}
开发者ID:smile-sa,项目名称:elasticsuite,代码行数:29,代码来源:Order.php
示例12: testCalcRowTotal
public function testCalcRowTotal()
{
$this->item->setData(['order_item_id' => 1, 'qty' => 2]);
$this->item->setInvoice($this->invoiceMock);
$this->invoiceMock->expects($this->once())->method('getOrder')->willReturn($this->orderMock);
$this->orderMock->expects($this->once())->method('getItemById')->with(1)->willReturn($this->orderItemMock);
$this->orderItemMock->expects($this->once())->method('getQtyOrdered')->willReturn(1);
$this->orderItemMock->expects($this->once())->method('getRowTotal')->willReturn(2);
$this->orderItemMock->expects($this->once())->method('getRowInvoiced')->willReturn(1);
$this->orderItemMock->expects($this->once())->method('getBaseRowTotal')->willReturn(2);
$this->orderItemMock->expects($this->once())->method('getBaseRowInvoiced')->willReturn(1);
$this->orderItemMock->expects($this->once())->method('getRowTotalInclTax')->willReturn(1);
$this->orderItemMock->expects($this->once())->method('getBaseRowTotalInclTax')->willReturn(1);
$this->orderItemMock->expects($this->once())->method('getQtyToInvoice')->willReturn(1);
$this->orderItemMock->expects($this->once())->method('getQtyInvoiced')->willReturn(0);
$this->invoiceMock->expects($this->exactly(4))->method('roundPrice')->willReturnMap([[2, 'regular', false, 2], [2, 'base', false, 2], [2, 'including', false, 2], [2, 'including_base', false, 2]]);
$this->assertEquals($this->item->calcRowTotal(), $this->item);
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:18,代码来源:ItemTest.php
示例13: testCollect
public function testCollect()
{
$this->creditmemoMock->expects($this->exactly(2))->method('setDiscountAmount')->willReturnSelf();
$this->creditmemoMock->expects($this->exactly(2))->method('setBaseDiscountAmount')->willReturnSelf();
$this->creditmemoMock->expects($this->once())->method('getOrder')->willReturn($this->orderMock);
$this->creditmemoMock->expects($this->once())->method('getBaseShippingAmount')->willReturn(1);
$this->orderMock->expects($this->once())->method('getBaseShippingDiscountAmount')->willReturn(1);
$this->orderMock->expects($this->exactly(2))->method('getBaseShippingAmount')->willReturn(1);
$this->orderMock->expects($this->once())->method('getShippingAmount')->willReturn(1);
$this->creditmemoMock->expects($this->once())->method('getAllItems')->willReturn([$this->creditmemoItemMock]);
$this->creditmemoItemMock->expects($this->atLeastOnce())->method('getOrderItem')->willReturn($this->orderItemMock);
$this->orderItemMock->expects($this->once())->method('isDummy')->willReturn(false);
$this->orderItemMock->expects($this->once())->method('getDiscountInvoiced')->willReturn(1);
$this->orderItemMock->expects($this->once())->method('getBaseDiscountInvoiced')->willReturn(1);
$this->orderItemMock->expects($this->once())->method('getQtyInvoiced')->willReturn(1);
$this->orderItemMock->expects($this->once())->method('getDiscountRefunded')->willReturn(1);
$this->orderItemMock->expects($this->once())->method('getQtyRefunded')->willReturn(0);
$this->creditmemoItemMock->expects($this->once())->method('isLast')->willReturn(false);
$this->creditmemoItemMock->expects($this->atLeastOnce())->method('getQty')->willReturn(1);
$this->creditmemoItemMock->expects($this->exactly(1))->method('setDiscountAmount')->willReturnSelf();
$this->creditmemoItemMock->expects($this->exactly(1))->method('setBaseDiscountAmount')->willReturnSelf();
$this->creditmemoMock->expects($this->exactly(2))->method('roundPrice')->willReturnMap([[1, 'regular', true, 1], [1, 'base', true, 1]]);
$this->assertEquals($this->total, $this->total->collect($this->creditmemoMock));
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:24,代码来源:DiscountTest.php
示例14: 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;
}
开发者ID:zhangjiachao,项目名称:magento2,代码行数:12,代码来源:Order.php
示例15: 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;
}
开发者ID:whoople,项目名称:magento2-testing,代码行数:31,代码来源:Create.php
示例16: getBaseTotalAmount
/**
* Calculate base total amount for the item
*
* @param QuoteItem|Item|InvoiceItem|CreditmemoItem $item
* @return mixed
*/
public function getBaseTotalAmount($item)
{
$baseTotalAmount = $item->getBaseRowTotal() - $item->getBaseDiscountAmount();
return $baseTotalAmount;
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:DefaultColumn.php
示例17: canShipItem
/**
* Checks if order item can be shipped.
*
* Dummy item can be shipped or with his children or
* with parent item which is included to shipment.
*
* @param \Magento\Sales\Model\Order\Item $item
* @param array $items
* @return bool
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function canShipItem($item, array $items = [])
{
if ($item->getIsVirtual() || $item->getLockedDoShip()) {
return false;
}
if ($item->isDummy(true)) {
if ($item->getHasChildren()) {
if ($item->isShipSeparately()) {
return true;
}
foreach ($item->getChildrenItems() as $child) {
if ($child->getIsVirtual()) {
continue;
}
if (empty($items)) {
if ($child->getQtyToShip() > 0) {
return true;
}
} else {
if (isset($items[$child->getId()]) && $items[$child->getId()] > 0) {
return true;
}
}
}
return false;
} elseif ($item->getParentItem()) {
$parent = $item->getParentItem();
if (empty($items)) {
return $parent->getQtyToShip() > 0;
} else {
return isset($items[$parent->getId()]) && $items[$parent->getId()] > 0;
}
}
} else {
return $item->getQtyToShip() > 0;
}
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:48,代码来源:ShipmentFactory.php
示例18: getBaseTotalAmount
/**
* Return the total amount minus discount
*
* @param OrderItem|InvoiceItem|CreditMemoItem $item
* @return mixed
*/
public function getBaseTotalAmount($item)
{
$totalAmount = $item->getBaseRowTotal() - $item->getBaseDiscountAmount() + $item->getBaseTaxAmount() + $item->getBaseHiddenTaxAmount() + $this->weeeHelper->getBaseRowWeeeTaxInclTax($item);
return $totalAmount;
}
开发者ID:zhangjiachao,项目名称:magento2,代码行数:11,代码来源:Renderer.php
示例19: isItemAvailableForReorder
/**
* Check item product availability for reorder
*
* @param \Magento\Sales\Model\Order\Item $orderItem
* @return boolean
*/
protected function isItemAvailableForReorder(\Magento\Sales\Model\Order\Item $orderItem)
{
try {
$stockItem = $this->stockRegistry->getStockItem($orderItem->getProduct()->getId(), $orderItem->getStore()->getWebsiteId());
return $stockItem->getIsInStock();
} catch (\Magento\Framework\Exception\NoSuchEntityException $noEntityException) {
return false;
}
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:LastOrderedItems.php
示例20: 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;
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:12,代码来源:Item.php
注:本文中的Magento\Sales\Model\Order\Item类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论