예제 #1
0
파일: Urlkey.php 프로젝트: aiesh/magento2
 /**
  * Refresh product rewrites
  *
  * @param \Magento\Framework\Object $object
  * @return $this
  */
 public function afterSave($object)
 {
     if ($object->dataHasChangedFor($this->getAttribute()->getName())) {
         $this->_catalogUrl->refreshProductRewrites(null, $object, true);
     }
     return $this;
 }
 /**
  * Build category URL path
  *
  * @param \Magento\Catalog\Api\Data\CategoryInterface|\Magento\Framework\Object $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;
 }
예제 #3
0
 /**
  * Tests \Magento\Framework\Object->setOrigData()
  */
 public function testOrigData()
 {
     $data = ['key1' => 'value1', 'key2' => 'value2'];
     $this->_object->setData($data);
     $this->_object->setOrigData();
     $this->_object->setData('key1', 'test');
     $this->assertTrue($this->_object->dataHasChangedFor('key1'));
     $this->assertEquals($data, $this->_object->getOrigData());
     $this->_object->setOrigData('key1', 'test');
     $this->assertEquals('test', $this->_object->getOrigData('key1'));
 }