-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathTemplateProcessor.php
45 lines (38 loc) · 1.62 KB
/
TemplateProcessor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
require dirname(__FILE__) . '/app/bootstrap.php';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
class Outslide extends \Magento\Framework\App\Http
implements \Magento\Framework\AppInterface {
public function launch()
{
$this->_state->setAreaCode('frontend');
// $this->_state->setAreaCode('adminhtml');
// $this->_state->setAreaCode(\Magento\Framework\App\Area::AREA_FRONTEND);
// $this->_state->setAreaCode(\Magento\Framework\App\Area::AREA_ADMINHTML);
$productRepository = $this->_objectManager->create('Magento\Catalog\Model\ProductRepository');
$filterProvider = $this->_objectManager->create('Magento\Cms\Model\Template\FilterProvider');
$storeManager = $this->_objectManager->create('Magento\Store\Model\StoreManagerInterface');
// YOU WANT TO LOAD BY ID?
$id = "YOUR ID HERE";
// YOU WANT TO LOAD BY SKU?
$sku = "YOUR SKU HERE";
if($id) {
$product = $productRepository->getById($id);
}
if($sku) {
$product = $productRepository->get($sku);
}
$descriptionAttributeCode = "description";
$storeId = $storeManager->getStore()->getId();
$description = $product->setStoreId($storeId)->getData($descriptionAttributeCode);
// echo $description;
$html = $filterProvider->getBlockFilter()->setStoreId($storeId)->filter($description);
echo $html;
echo 'Done!';
//the method must end with this line
return $this->_response;
}
}
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication('Outslide');
$bootstrap->run($app);