本文整理汇总了PHP中Magento\Framework\DataObject::getShipment方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObject::getShipment方法的具体用法?PHP DataObject::getShipment怎么用?PHP DataObject::getShipment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\DataObject
的用法示例。
在下文中一共展示了DataObject::getShipment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSave
/**
* Performed before data is saved
*
* @param \Magento\Framework\DataObject $object
* @return $this
*/
public function beforeSave($object)
{
if ($object->getShipment()) {
$object->setParentId($object->getShipment()->getId());
}
return parent::beforeSave($object);
}
示例2: getChildren
/**
* Getting all available children for Invoice, Shipment or CreditMemo item
*
* @param \Magento\Framework\DataObject $item
* @return array|null
*/
public function getChildren($item)
{
$itemsArray = [];
$items = null;
if ($item instanceof \Magento\Sales\Model\Order\Invoice\Item) {
$items = $item->getInvoice()->getAllItems();
} elseif ($item instanceof \Magento\Sales\Model\Order\Shipment\Item) {
$items = $item->getShipment()->getAllItems();
} elseif ($item instanceof \Magento\Sales\Model\Order\Creditmemo\Item) {
$items = $item->getCreditmemo()->getAllItems();
}
if ($items) {
foreach ($items as $value) {
$parentItem = $value->getOrderItem()->getParentItem();
if ($parentItem) {
$itemsArray[$parentItem->getId()][$value->getOrderItemId()] = $value;
} else {
$itemsArray[$value->getOrderItem()->getId()][$value->getOrderItemId()] = $value;
}
}
}
if (isset($itemsArray[$item->getOrderItem()->getId()])) {
return $itemsArray[$item->getOrderItem()->getId()];
} else {
return null;
}
}
示例3: afterCanDisplayCustomValue
/**
* @param \Magento\Framework\DataObject $subject
* @param bool $result
* @return bool
*/
public function afterCanDisplayCustomValue(\Magento\Framework\DataObject $subject, $result)
{
$carrierCode = $subject->getShipment()->getCarrierCode();
if (!$carrierCode) {
return (bool) $result || false;
}
return (bool) $result || (bool) $carrierCode == \Magento\Fedex\Model\Carrier::CODE;
}