Skip to content

Commit a4a94d0

Browse files
committed
Create TemplateProcessor.php
1 parent fe9a6fe commit a4a94d0

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

Diff for: TemplateProcessor.php

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

0 commit comments

Comments
 (0)