本文整理汇总了PHP中Magento\Framework\Model\AbstractModel::getParentId方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractModel::getParentId方法的具体用法?PHP AbstractModel::getParentId怎么用?PHP AbstractModel::getParentId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Model\AbstractModel
的用法示例。
在下文中一共展示了AbstractModel::getParentId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _beforeSave
/**
* @param \Magento\Framework\Model\AbstractModel $object
* @return $this
*/
protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
{
/**@var $object \Magento\Sales\Model\Order\Creditmemo\Item*/
if (!$object->getParentId() && $object->getCreditmemo()) {
$object->setParentId($object->getCreditmemo()->getId());
}
return parent::_beforeSave($object);
}
示例2: _beforeSave
/**
* Perform actions before object save
*
* @param \Magento\Framework\Model\AbstractModel|\Magento\Framework\DataObject $object
* @return $this
*/
protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
{
/** @var \Magento\Sales\Model\Order\Invoice\Item $object */
if (!$object->getParentId() && $object->getInvoice()) {
$object->setParentId($object->getInvoice()->getId());
}
return parent::_beforeSave($object);
}
示例3: _beforeSave
/**
* Performs validation before save
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
{
/** @var \Magento\Sales\Model\Order\Shipment\Comment $object */
if (!$object->getParentId() && $object->getShipment()) {
$object->setParentId($object->getShipment()->getId());
}
parent::_beforeSave($object);
$errors = $this->validator->validate($object);
if (!empty($errors)) {
throw new \Magento\Framework\Exception\LocalizedException(__("Cannot save comment:\n%1", implode("\n", $errors)));
}
return $this;
}
示例4: getUrlPath
/**
* Build category URL path
*
* @param \Magento\Catalog\Api\Data\CategoryInterface|\Magento\Framework\Model\AbstractModel $category
* @return string
*/
public function getUrlPath($category)
{
if ($category->getParentId() == Category::TREE_ROOT_ID) {
return '';
}
$path = $category->getUrlPath();
if ($path !== null && !$category->dataHasChangedFor('url_key') && !$category->dataHasChangedFor('parent_id')) {
return $path;
}
$path = $category->getUrlKey();
if ($path === false) {
return $category->getUrlPath();
}
if ($this->isNeedToGenerateUrlPathForParent($category)) {
$parentPath = $this->getUrlPath($this->categoryRepository->get($category->getParentId()));
$path = $parentPath === '' ? $path : $parentPath . '/' . $path;
}
return $path;
}