本文整理汇总了PHP中Magento\Framework\Object::getPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::getPath方法的具体用法?PHP Object::getPath怎么用?PHP Object::getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Object
的用法示例。
在下文中一共展示了Object::getPath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _afterSave
/**
* Process category data after save category object
* save related products ids and update path value
*
* @param \Magento\Framework\Object $object
* @return $this
*/
protected function _afterSave(\Magento\Framework\Object $object)
{
/**
* Add identifier for new category
*/
if (substr($object->getPath(), -1) == '/') {
$object->setPath($object->getPath() . $object->getId());
$this->_savePath($object);
}
$this->_saveCategoryProducts($object);
return parent::_afterSave($object);
}
示例2: loadCategoryChilds
/**
* Retrieve category child data objects
*
* @param \Magento\Framework\Object $category
* @return \Magento\Framework\Object
*/
public function loadCategoryChilds(\Magento\Framework\Object $category)
{
if ($category->getId() === null || $category->getStoreId() === null) {
return $category;
}
$categories = $this->_getCategories(null, $category->getStoreId(), $category->getPath() . '/');
$category->setChilds(array());
foreach ($categories as $child) {
if (!is_array($child->getChilds())) {
$child->setChilds(array());
}
if ($child->getParentId() == $category->getId()) {
$category->setChilds($category->getChilds() + array($child->getId() => $child));
} else {
if (isset($categories[$child->getParentId()])) {
if (!is_array($categories[$child->getParentId()]->getChilds())) {
$categories[$child->getParentId()]->setChilds(array());
}
$categories[$child->getParentId()]->setChilds($categories[$child->getParentId()]->getChilds() + array($child->getId() => $child));
}
}
}
$category->setAllChilds($categories);
return $category;
}
示例3: _prepareCategoryParentId
/**
* Prepare category parentId
*
* @param \Magento\Framework\Object $category
* @return $this
*/
protected function _prepareCategoryParentId(\Magento\Framework\Object $category)
{
if ($category->getPath() != $category->getId()) {
$split = explode('/', $category->getPath());
$category->setParentId($split[count($split) - 2]);
} else {
$category->setParentId(0);
}
return $this;
}
示例4: _refreshProductRewrite
/**
* Refresh product rewrite
*
* @param \Magento\Framework\Object $product
* @param \Magento\Framework\Object $category
* @return $this
*/
protected function _refreshProductRewrite(\Magento\Framework\Object $product, \Magento\Framework\Object $category)
{
if ($category->getId() == $category->getPath()) {
return $this;
}
if ($product->getUrlKey() == '') {
$urlKey = $this->productUrl->formatUrlKey($product->getName());
} else {
$urlKey = $this->productUrl->formatUrlKey($product->getUrlKey());
}
$idPath = $this->generatePath('id', $product, $category);
$targetPath = $this->generatePath('target', $product, $category);
$requestPath = $this->getProductRequestPath($product, $category);
$categoryId = null;
$updateKeys = true;
if ($category->getLevel() > 1) {
$categoryId = $category->getId();
$updateKeys = false;
}
$rewriteData = array('store_id' => $category->getStoreId(), 'category_id' => $categoryId, 'product_id' => $product->getId(), 'id_path' => $idPath, 'request_path' => $requestPath, 'target_path' => $targetPath, 'is_system' => 1);
$this->getResource()->saveRewrite($rewriteData, $this->_rewrite);
if ($this->getShouldSaveRewritesHistory($category->getStoreId())) {
$this->_saveRewriteHistory($rewriteData, $this->_rewrite);
}
if ($updateKeys && $product->getUrlKey() != $urlKey) {
$product->setUrlKey($urlKey);
$this->getResource()->saveProductAttribute($product, 'url_key');
}
if ($updateKeys && $product->getUrlPath() != $requestPath) {
$product->setUrlPath($requestPath);
$this->getResource()->saveProductAttribute($product, 'url_path');
}
return $this;
}