当前位置: 首页>>代码示例>>PHP>>正文


PHP Object::getName方法代码示例

本文整理汇总了PHP中Magento\Framework\Object::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::getName方法的具体用法?PHP Object::getName怎么用?PHP Object::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Object的用法示例。


在下文中一共展示了Object::getName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetAllItems

 public function testGetAllItems()
 {
     $totals = $this->_prepareValidModelData();
     $this->assertEquals([new \Magento\Framework\Object(['name' => $this->_validItem->getName(), 'qty' => $this->_validItem->getQty(), 'amount' => $this->_validItem->getPrice()])], $this->_model->getAllItems());
     $this->assertEquals($totals['subtotal'], $this->_model->getSubtotal());
     $this->assertEquals($totals['tax'], $this->_model->getTax());
     $this->assertEquals($totals['shipping'], $this->_model->getShipping());
     $this->assertEquals($totals['discount'], $this->_model->getDiscount());
 }
开发者ID:nja78,项目名称:magento2,代码行数:9,代码来源:CartTest.php

示例2: beforeSave

 /**
  * Before save
  *
  * @param \Magento\Framework\Object $object
  * @return $this
  */
 public function beforeSave($object)
 {
     $attributeName = $this->getAttribute()->getName();
     $urlKey = $object->getData($attributeName);
     if ($urlKey == '') {
         $urlKey = $object->getName();
     }
     $object->setData($attributeName, $object->formatUrlKey($urlKey));
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:16,代码来源:Urlkey.php

示例3: buildNodeName

 /**
  * Get category name
  *
  * @param \Magento\Framework\Object $node
  * @return string
  */
 public function buildNodeName($node)
 {
     $result = $this->escapeHtml($node->getName());
     if ($this->_withProductCount) {
         $result .= ' (' . $node->getProductCount() . ')';
     }
     return $result;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:Tree.php

示例4: getFileName

 /**
  * File name URL getter
  *
  * @param  \Magento\Framework\Object $file
  * @return string
  */
 public function getFileName(\Magento\Framework\Object $file)
 {
     return $file->getName();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:10,代码来源:Files.php

示例5: getSearchUrl

 /**
  * @param \Magento\Framework\Object $obj
  * @return string
  */
 public function getSearchUrl($obj)
 {
     /** @var $url UrlInterface */
     $url = $this->_urlFactory->create();
     /*
      * url encoding will be done in Url.php http_build_query
      * so no need to explicitly called urlencode for the text
      */
     $url->setQueryParam('q', $obj->getName());
     return $url->getUrl('catalogsearch/result');
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:15,代码来源:Term.php

示例6: generatePath

 /**
  * Generate either id path, request path or target path for product and/or category
  *
  * For generating id or system path, either product or category is required
  * For generating request path - category is required
  * $parentPath used only for generating category path
  *
  * @param string $type
  * @param \Magento\Framework\Object $product
  * @param \Magento\Framework\Object $category
  * @param string $parentPath
  * @return string
  * @throws \Magento\Framework\Model\Exception
  */
 public function generatePath($type = 'target', $product = null, $category = null, $parentPath = null)
 {
     if (!$product && !$category) {
         throw new \Magento\Framework\Model\Exception(__('Please specify either a category or a product, or both.'));
     }
     // generate id_path
     if ('id' === $type) {
         if (!$product) {
             return 'category/' . $category->getId();
         }
         if ($category && $category->getLevel() > 1) {
             return 'product/' . $product->getId() . '/' . $category->getId();
         }
         return 'product/' . $product->getId();
     }
     // generate request_path
     if ('request' === $type) {
         // for category
         if (!$product) {
             if ($category->getUrlKey() == '') {
                 $urlKey = $this->getCategoryModel()->formatUrlKey($category->getName());
             } else {
                 $urlKey = $this->getCategoryModel()->formatUrlKey($category->getUrlKey());
             }
             $categoryUrlSuffix = $this->getCategoryUrlSuffix($category->getStoreId());
             if (null === $parentPath) {
                 $parentPath = $this->getResource()->getCategoryParentPath($category);
             } elseif ($parentPath == '/') {
                 $parentPath = '';
             }
             $parentPath = $this->_catalogCategory->getCategoryUrlPath($parentPath, true, $category->getStoreId());
             return $this->getUnusedPath($category->getStoreId(), $parentPath . $urlKey . $categoryUrlSuffix, $this->generatePath('id', null, $category), $urlKey);
         }
         // for product & category
         if (!$category) {
             throw new \Magento\Framework\Model\Exception(__('A category object is required for determining the product request path.'));
         }
         if ($product->getUrlKey() == '') {
             $urlKey = $this->productUrl->formatUrlKey($product->getName());
         } else {
             $urlKey = $this->productUrl->formatUrlKey($product->getUrlKey());
         }
         $productUrlSuffix = $this->getProductUrlSuffix($category->getStoreId());
         if ($category->getLevel() > 1) {
             // To ensure, that category has url path either from attribute or generated now
             $this->_addCategoryUrlPath($category);
             $categoryUrl = $this->_catalogCategory->getCategoryUrlPath($category->getUrlPath(), false, $category->getStoreId());
             return $this->getUnusedPath($category->getStoreId(), $categoryUrl . '/' . $urlKey . $productUrlSuffix, $this->generatePath('id', $product, $category), $urlKey);
         }
         // for product only
         return $this->getUnusedPath($category->getStoreId(), $urlKey . $productUrlSuffix, $this->generatePath('id', $product), $urlKey);
     }
     // generate target_path
     if (!$product) {
         return 'catalog/category/view/id/' . $category->getId();
     }
     if ($category && $category->getLevel() > 1) {
         return 'catalog/product/view/id/' . $product->getId() . '/category/' . $category->getId();
     }
     return 'catalog/product/view/id/' . $product->getId();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:75,代码来源:Url.php


注:本文中的Magento\Framework\Object::getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。