Product.php 978 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * Product controller.
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\Catalog\Controller;
  9. use Magento\Catalog\Controller\Product\View\ViewInterface;
  10. use Magento\Catalog\Model\Product as ModelProduct;
  11. abstract class Product extends \Magento\Framework\App\Action\Action implements ViewInterface
  12. {
  13. /**
  14. * Initialize requested product object
  15. *
  16. * @return ModelProduct
  17. */
  18. protected function _initProduct()
  19. {
  20. $categoryId = (int)$this->getRequest()->getParam('category', false);
  21. $productId = (int)$this->getRequest()->getParam('id');
  22. $params = new \Magento\Framework\DataObject();
  23. $params->setCategoryId($categoryId);
  24. /** @var \Magento\Catalog\Helper\Product $product */
  25. $product = $this->_objectManager->get(\Magento\Catalog\Helper\Product::class);
  26. return $product->initProduct($productId, $this, $params);
  27. }
  28. }