Example #1
0
 /**
  * Load specific layout handles by product type id
  *
  * @param CatalogProduct $product
  * @return \Magento\Framework\View\Result\Page
  */
 protected function getProductPage($product)
 {
     /** @var \Magento\Framework\View\Result\Page $resultPage */
     $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
     if ($product->getPageLayout()) {
         $resultPage->getConfig()->setPageLayout($product->getPageLayout());
     }
     $urlSafeSku = rawurlencode($product->getSku());
     $resultPage->addPageLayoutHandles(['id' => $product->getId(), 'sku' => $urlSafeSku, 'type' => $product->getTypeId()]);
     $resultPage->addUpdate($product->getCustomLayoutUpdate());
     return $resultPage;
 }
Example #2
0
 /**
  * Load specific layout handles by product type id
  *
  * @param CatalogProduct $product
  * @return void
  */
 protected function _initProductLayout($product)
 {
     $this->_view->getPage()->initLayout();
     if ($product->getPageLayout()) {
         /** @var \Magento\Framework\View\Page\Config $pageConfig */
         $pageConfig = $this->_objectManager->get('Magento\\Framework\\View\\Page\\Config');
         $pageConfig->setPageLayout($product->getPageLayout());
     }
     $update = $this->_view->getLayout()->getUpdate();
     $this->_view->addPageLayoutHandles(array('id' => $product->getId(), 'sku' => $product->getSku(), 'type' => $product->getTypeId()));
     $this->_view->loadLayoutUpdates();
     $update->addUpdate($product->getCustomLayoutUpdate());
     $this->_view->generateLayoutXml();
     $this->_view->generateLayoutBlocks();
 }
Example #3
0
 /**
  * Load specific layout handles by product type id
  *
  * @param CatalogProduct $product
  * @return void
  */
 protected function _initProductLayout($product)
 {
     $update = $this->_view->getLayout()->getUpdate();
     $update->addHandle('default');
     $this->_view->addPageLayoutHandles(array('id' => $product->getId(), 'sku' => $product->getSku(), 'type' => $product->getTypeId()));
     if ($product->getPageLayout()) {
         $this->_objectManager->get('Magento\\Theme\\Helper\\Layout')->applyHandle($product->getPageLayout());
     }
     $this->_view->loadLayoutUpdates();
     if ($product->getPageLayout()) {
         $this->_objectManager->get('Magento\\Theme\\Helper\\Layout')->applyTemplate($product->getPageLayout());
     }
     $update->addUpdate($product->getCustomLayoutUpdate());
     $this->_view->generateLayoutXml();
     $this->_view->generateLayoutBlocks();
 }
Example #4
0
 /**
  * Extract custom layout settings from category or product object
  *
  * @param \Magento\Catalog\Model\Category|\Magento\Catalog\Model\Product $object
  * @return \Magento\Framework\Object
  */
 protected function _extractSettings($object)
 {
     $settings = new \Magento\Framework\Object();
     if (!$object) {
         return $settings;
     }
     $date = $object->getCustomDesignDate();
     if (array_key_exists('from', $date) && array_key_exists('to', $date) && $this->_localeDate->isScopeDateInInterval(null, $date['from'], $date['to'])) {
         $settings->setCustomDesign($object->getCustomDesign())->setPageLayout($object->getPageLayout())->setLayoutUpdates((array) $object->getCustomLayoutUpdate());
     }
     return $settings;
 }