@@ 495-510 (lines=16) @@ | ||
492 | * @return array The category |
|
493 | * @throws \Exception Is thrown, if the requested category is not available |
|
494 | */ |
|
495 | public function getCategoryByPath($path, $storeViewCode = StoreViewCodes::ADMIN) |
|
496 | { |
|
497 | ||
498 | // load the categories by the passed store view code |
|
499 | $categories = $this->getCategoriesByStoreViewCode($storeViewCode); |
|
500 | ||
501 | // query whether or not the category with the passed path exists |
|
502 | if (isset($categories[$path])) { |
|
503 | return $categories[$path]; |
|
504 | } |
|
505 | ||
506 | // throw an exception, if not |
|
507 | throw new \Exception( |
|
508 | $this->appendExceptionSuffix( |
|
509 | sprintf('Can\'t find category with path %s', $path) |
|
510 | ) |
|
511 | ); |
|
512 | } |
|
513 | ||
@@ 547-564 (lines=18) @@ | ||
544 | * @return array The category data |
|
545 | * @throws \Exception Is thrown, if the category is not available |
|
546 | */ |
|
547 | public function getCategory($categoryId, $storeViewCode = StoreViewCodes::ADMIN) |
|
548 | { |
|
549 | ||
550 | // retrieve the categories with for the passed store view code |
|
551 | $categories = $this->getCategoriesByStoreViewCode($storeViewCode); |
|
552 | ||
553 | // try to load the category with the passed ID |
|
554 | foreach ($categories as $category) { |
|
555 | if ($category[MemberNames::ENTITY_ID] == $categoryId) { |
|
556 | return $category; |
|
557 | } |
|
558 | } |
|
559 | ||
560 | // throw an exception if the category is NOT available |
|
561 | throw new \Exception( |
|
562 | $this->appendExceptionSuffix( |
|
563 | sprintf('Can\'t load category with ID %d', $categoryId) |
|
564 | ) |
|
565 | ); |
|
566 | } |
|
567 |