18 class Product extends \Magento\Framework\Url\Helper\Data
113 \
Magento\Framework\View\Asset\Repository $assetRepo,
114 \
Magento\Framework\Registry $coreRegistry,
116 $reindexPriceIndexerData,
117 $reindexProductCategoryIndexerData,
121 $this->_catalogSession = $catalogSession;
122 $this->_attributeConfig = $attributeConfig;
123 $this->_coreRegistry = $coreRegistry;
124 $this->_assetRepo = $assetRepo;
125 $this->_reindexPriceIndexerData = $reindexPriceIndexerData;
128 $this->_reindexProductCategoryIndexerData = $reindexProductCategoryIndexerData;
130 parent::__construct($context);
142 foreach ($this->_reindexPriceIndexerData[
'byDataResult'] as $param) {
143 if (
$data->getData($param)) {
147 foreach ($this->_reindexPriceIndexerData[
'byDataChange'] as $param) {
148 if (
$data->dataHasChangedFor($param)) {
153 foreach ($this->_reindexPriceIndexerData[
'byDataChange'] as $param) {
154 if (isset(
$data[$param])) {
170 foreach ($this->_reindexProductCategoryIndexerData[
'byDataChange'] as $param) {
171 if (
$data->dataHasChangedFor($param)) {
189 return $this->productRepository->getById(
$product)->getProductUrl();
227 $url = $this->_assetRepo->getUrl(
'Magento_Catalog::images/product/placeholder/image.jpg');
245 $url = $this->_assetRepo->getUrl(
'Magento_Catalog::images/product/placeholder/small_image.jpg');
263 $url = $this->_assetRepo->getUrl(
'Magento_Catalog::images/product/placeholder/thumbnail.jpg');
277 $category = $this->_coreRegistry->registry(
'current_category');
281 return $this->
_getUrl(
'sendfriend/product/send', [
'id' =>
$product->getId(),
'cat_id' => $categoryId]);
289 if (
null === $this->_statuses) {
290 $this->_statuses = [];
317 return $product->isVisibleInCatalog() &&
$product->isVisibleInSiteVisibility();
328 return $this->scopeConfig->getValue(
329 self::XML_PATH_USE_PRODUCT_CANONICAL_TAG,
349 'multiselect' => [
'backend_model' => \Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend::class],
350 'boolean' => [
'source_model' => \Magento\Eav\Model\Entity\Attribute\Source\Boolean::class],
353 if ($inputType ===
null) {
356 if (isset($inputTypes[$inputType])) {
357 return $inputTypes[$inputType];
372 if (!empty($inputTypes[$inputType][
'backend_model'])) {
373 return $inputTypes[$inputType][
'backend_model'];
387 if (!empty($inputTypes[$inputType][
'source_model'])) {
388 return $inputTypes[$inputType][
'source_model'];
411 $params = new \Magento\Framework\DataObject();
415 $this->_eventManager->dispatch(
416 'catalog_controller_product_init_before',
425 $product = $this->productRepository->getById(
$productId,
false, $this->_storeManager->getStore()->getId());
433 if (!in_array($this->_storeManager->getStore()->getWebsiteId(),
$product->getWebsiteIds())) {
438 $categoryId =
$params->getCategoryId();
439 if (!$categoryId && $categoryId !==
false) {
440 $lastId = $this->_catalogSession->getLastVisitedCategoryId();
441 if (
$product->canBeShowInCategory($lastId)) {
442 $categoryId = $lastId;
450 $category = $this->categoryRepository->get($categoryId);
456 $this->_coreRegistry->register(
'current_category',
$category);
461 $this->_coreRegistry->register(
'current_product',
$product);
462 $this->_coreRegistry->register(
'product',
$product);
465 $this->_eventManager->dispatch(
466 'catalog_controller_product_init_after',
469 }
catch (\
Magento\Framework\Exception\LocalizedException $e) {
470 $this->_logger->critical($e);
489 $product->setPreconfiguredValues($optionValues);
518 $currentConfig =
$params->getCurrentConfig();
519 if ($currentConfig) {
520 if (is_array($currentConfig)) {
521 $params->setCurrentConfig(
new \
Magento\Framework\DataObject($currentConfig));
522 }
elseif (!$currentConfig instanceof \
Magento\Framework\DataObject) {
531 $processingParams =
$buyRequest->getData(
'_processing_params');
532 if (!$processingParams || !$processingParams instanceof \
Magento\Framework\DataObject) {
533 $processingParams = new \Magento\Framework\DataObject();
534 $buyRequest->setData(
'_processing_params', $processingParams);
536 $processingParams->addData(
$params->getData());
551 $this->_skipSaleableCheck = $skipSaleableCheck;
583 return $this->_attributeConfig->getAttributeNames(
'used_in_autogeneration');
elseif(isset( $params[ 'redirect_parent']))
const XML_PATH_AUTO_GENERATE_MASK
getAttributeBackendModelByInputType($inputType)
getEmailToFriendUrl($product)
__construct(\Magento\Framework\App\Helper\Context $context, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Session $catalogSession, \Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Framework\Registry $coreRegistry, \Magento\Catalog\Model\Attribute\Config $attributeConfig, $reindexPriceIndexerData, $reindexProductCategoryIndexerData, ProductRepositoryInterface $productRepository, CategoryRepositoryInterface $categoryRepository)
addParamsToBuyRequest($buyRequest, $params)
prepareProductOptions($product, $buyRequest)
const XML_PATH_PRODUCT_URL_USE_CATEGORY
_getUrl($route, $params=[])
$_reindexPriceIndexerData
isDataForPriceIndexerWasChanged($data)
isDataForProductCategoryIndexerWasChanged(\Magento\Catalog\Model\Product $data)
getThumbnailUrl($product)
getAttributeInputTypes($inputType=null)
foreach($product->getExtensionAttributes() ->getBundleProductOptions() as $option) $buyRequest
initProduct($productId, $controller, $params=null)
const XML_PATH_USE_PRODUCT_CANONICAL_TAG
$_reindexProductCategoryIndexerData
setSkipSaleableCheck($skipSaleableCheck=false)
getSmallImageUrl($product)
canShow($product, $where='catalog')
canUseCanonicalTag($store=null)
getFieldsAutogenerationMasks()
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
getAttributesAllowedForAutogeneration()
getAttributeSourceModelByInputType($inputType)