Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use Magento\Catalog\Api\Data\ProductInterface;
- use Magento\Catalog\Api\ProductRepositoryInterface;
- use Psr\Log\LoggerInterface;
- class Test
- {
- /**
- * @var LoggerInterface
- */
- private $logger;
- public function __construct(LoggerInterface $logger)
- {
- $this->logger = $logger;
- }
- public function beforeGetById(
- ProductRepositoryInterface $subject,
- $productId,
- $editMode = false,
- $storeId = null,
- $forceReload = false
- ) {
- $this->logger->info("Before");
- return [$productId, $editMode, $storeId, $forceReload];
- }
- public function afterGetById(ProductRepositoryInterface $subject, ProductInterface $result)
- {
- $this->logger->info("After");
- return $result;
- }
- public function aroundGetById(
- ProductRepositoryInterface $subject,
- callable $proceed,
- $productId,
- $editMode = false,
- $storeId = null,
- $forceReload = false
- ) {
- $this->logger->info("Around (before)");
- $result = $proceed($productId, $editMode, $storeId, $forceReload);
- $this->logger->info("Around (after)");
- return $result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement