本文整理匯總了PHP中Magento\Quote\Model\Quote\Item::toArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP Item::toArray方法的具體用法?PHP Item::toArray怎麽用?PHP Item::toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Quote\Model\Quote\Item
的用法示例。
在下文中一共展示了Item::toArray方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testToArray
public function testToArray()
{
$productMock = $this->generateProductMock(self::PRODUCT_ID, self::PRODUCT_TYPE, self::PRODUCT_SKU, self::PRODUCT_NAME, self::PRODUCT_WEIGHT, self::PRODUCT_TAX_CLASS_ID, self::PRODUCT_COST);
$this->model->setProduct($productMock);
$toArrayValue = ['a' => 'b'];
$productMock->expects($this->once())->method('toArray')->will($this->returnValue($toArrayValue));
$data = $this->model->toArray();
$this->assertEquals($toArrayValue, $data['product']);
}
示例2: modelToDataObject
/**
* Converts a specified rate model to a shipping method data object.
*
* @param \Magento\Quote\Model\Quote\Item $item
* @return array
* @throws \Exception
*/
public function modelToDataObject($item)
{
$this->eventManager->dispatch('items_additional_data', ['item' => $item]);
$items = $item->toArray();
$items['options'] = $this->getFormattedOptionValue($item);
$itemsData = $this->totalsItemFactory->create();
$this->dataObjectHelper->populateWithArray($itemsData, $items, '\\Magento\\Quote\\Api\\Data\\TotalsItemInterface');
return $itemsData;
}