Filter product with Ajax and return Json Array from a controller to show in a phtml fileHow to create the an ajax call to return spConfig json with product sku (product options)pass data from phtml file to controllerReturn bool gives error “Invalid return type” for Ajax ControllerRetreive and return response from controller in magento2Magento 1.9.3.3 - How do you return a JSON array from a controller to ajaxMagento2, need help with ajax return data processing from controller which is string of html tagsMagento 2 - Send form data to Controller using AJAX and return Result to PHTMLreturn array of json after call ajax magento 1.9.3.xreturn phtml file content in ajax response in magento2Return as json instead of Html from controller renderlayout
TeX Gyre Pagella Math Integral sign much too small
What are these round pads on the bottom of a PCB?
Hexagonal Grid Filling
Do Monks gain the 9th level Unarmored Movement benefit when wearing armor or using a shield?
Double underlining a result in a system of equations with calculation steps on the right side
Is it a Munchausen Number?
What dice to use in a game that revolves around triangles?
Why did they wait for Quill to arrive?
Did the IBM System/4 Pi computer have radiation-hardened versions for Skylab and Shuttle?
Row vectors and column vectors (Mathematica vs Matlab)
Is it a good idea to copy a trader when investing?
Program for finding longest run of zeros from a list of 100 random integers which are either 0 or 1
What's the "magic similar to the Knock spell" referenced in the Dungeon of the Mad Mage adventure?
Can the president of the United States be guilty of insider trading?
What is the status of the three crises in the history of mathematics?
Is it safe to keep the GPU on 100% utilization for a very long time?
How long can fsck take on a 30 TB volume?
Why does the electron wavefunction not collapse within atoms at room temperature in gas, liquids or solids due to decoherence?
Can a planet still function with a damaged moon?
Why is valarray so slow on VS2015?
Publishing an article in a journal without a related degree
How can I test a shell script in a "safe environment" to avoid harm to my computer?
Ugin's Conjurant vs. un-preventable damage
Does STATISTICS IO output include Version Store reads?
Filter product with Ajax and return Json Array from a controller to show in a phtml file
How to create the an ajax call to return spConfig json with product sku (product options)pass data from phtml file to controllerReturn bool gives error “Invalid return type” for Ajax ControllerRetreive and return response from controller in magento2Magento 1.9.3.3 - How do you return a JSON array from a controller to ajaxMagento2, need help with ajax return data processing from controller which is string of html tagsMagento 2 - Send form data to Controller using AJAX and return Result to PHTMLreturn array of json after call ajax magento 1.9.3.xreturn phtml file content in ajax response in magento2Return as json instead of Html from controller renderlayout
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Is it possible to return an array from a controller or from a block function to the phtml file?
<?php
namespace MnuhellFormSearchAttributesControllerIndex;
use MagentoFrameworkAppActionAction;
use MagentoFrameworkAppActionContext;
use MagentoFrameworkControllerResultJsonFactory;
use MagentoFrameworkRegistry;
use MagentoFrameworkViewResultPageFactory;
class Search extends Action
/**
* @var PageFactory
*/
protected $_resultPageFactory;
protected $_resultJsonFactory;
protected $_coreRegistry;
public function __construct(Context $context, PageFactory $resultPageFactory, JsonFactory $_resultJsonFactory, Registry $_coreRegistry)
$this->_resultPageFactory = $resultPageFactory;
$this->_resultJsonFactory = $_resultJsonFactory;
$this->_coreRegistry = $_coreRegistry;
parent::__construct($context);
public function execute()
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
$connection = $resource->getConnection();
$minPrice = $this->getRequest()->getParam('minPrice');
$maxPrice = $this->getRequest()->getParam('maxPrice');
$minQty = $this->getRequest()->getParam('minQty');
$maxQty = $this->getRequest()->getParam('maxQty');
//$category = $this->getRequest()->getParam('category');
if($minPrice != "undefined" AND $maxPrice != "undefined" AND $minQty == "undefined" AND $maxQty == "undefined")
$sql = "SELECT cat.entity_id, cat1.value, count(prod.entity_id) AS totals FROM catalog_category_entity as cat
LEFT JOIN catalog_category_entity_varchar as cat1 ON cat.entity_id = cat1.entity_id
INNER JOIN catalog_category_product as catprod ON catprod.category_id = cat.entity_id
INNER JOIN catalog_product_entity as prod ON prod.entity_id = catprod.product_id
LEFT JOIN catalog_product_entity_decimal as prec on prec.entity_id = prod.entity_id
LEFT JOIN cataloginventory_stock_item AS stock ON stock.product_id = prod.entity_id
where children_count > 0 and cat1.attribute_id = 45 and cat.entity_id > 2
AND prec.value > $minPrice and prec.value < $maxPrice
group by cat.entity_id ";
$result = $connection->fetchAll($sql);
if($minPrice != "undefined" AND $maxPrice != "undefined" AND $minQty != "undefined" AND $maxQty != "undefined")
$sql = "SELECT cat.entity_id, cat1.value, count(prod.entity_id) AS totals FROM catalog_category_entity as cat
LEFT JOIN catalog_category_entity_varchar as cat1 ON cat.entity_id = cat1.entity_id
INNER JOIN catalog_category_product as catprod ON catprod.category_id = cat.entity_id
INNER JOIN catalog_product_entity as prod ON prod.entity_id = catprod.product_id
LEFT JOIN catalog_product_entity_decimal as prec on prec.entity_id = prod.entity_id
LEFT JOIN cataloginventory_stock_item AS stock ON stock.product_id = prod.entity_id
where children_count > 0 and cat1.attribute_id = 45 and cat.entity_id > 2
AND prec.value > $minPrice AND prec.value < $maxPrice
AND stock.qty > $minQty group by cat.entity_id";
$result = $connection->fetchAll($sql);
$sql = "SELECT cat.entity_id, cat1.value, count(prod.entity_id) AS totals FROM catalog_category_entity as cat
LEFT JOIN catalog_category_entity_varchar as cat1 ON cat.entity_id = cat1.entity_id
INNER JOIN catalog_category_product as catprod ON catprod.category_id = cat.entity_id
INNER JOIN catalog_product_entity as prod ON prod.entity_id = catprod.product_id
LEFT JOIN catalog_product_entity_decimal as prec on prec.entity_id = prod.entity_id
LEFT JOIN cataloginventory_stock_item AS stock ON stock.product_id = prod.entity_id
where children_count > 0 and cat1.attribute_id = 45 and cat.entity_id > 2 group by cat.entity_id";
$result = $connection->fetchAll($sql);
$resultJson = $this->_resultJsonFactory->create($result);
$collection = $resultJson->setData($result);
return $collection;
How I can return collection array json in a phtml file?
Thanks!!
magento2 product ajax filter
add a comment |
Is it possible to return an array from a controller or from a block function to the phtml file?
<?php
namespace MnuhellFormSearchAttributesControllerIndex;
use MagentoFrameworkAppActionAction;
use MagentoFrameworkAppActionContext;
use MagentoFrameworkControllerResultJsonFactory;
use MagentoFrameworkRegistry;
use MagentoFrameworkViewResultPageFactory;
class Search extends Action
/**
* @var PageFactory
*/
protected $_resultPageFactory;
protected $_resultJsonFactory;
protected $_coreRegistry;
public function __construct(Context $context, PageFactory $resultPageFactory, JsonFactory $_resultJsonFactory, Registry $_coreRegistry)
$this->_resultPageFactory = $resultPageFactory;
$this->_resultJsonFactory = $_resultJsonFactory;
$this->_coreRegistry = $_coreRegistry;
parent::__construct($context);
public function execute()
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
$connection = $resource->getConnection();
$minPrice = $this->getRequest()->getParam('minPrice');
$maxPrice = $this->getRequest()->getParam('maxPrice');
$minQty = $this->getRequest()->getParam('minQty');
$maxQty = $this->getRequest()->getParam('maxQty');
//$category = $this->getRequest()->getParam('category');
if($minPrice != "undefined" AND $maxPrice != "undefined" AND $minQty == "undefined" AND $maxQty == "undefined")
$sql = "SELECT cat.entity_id, cat1.value, count(prod.entity_id) AS totals FROM catalog_category_entity as cat
LEFT JOIN catalog_category_entity_varchar as cat1 ON cat.entity_id = cat1.entity_id
INNER JOIN catalog_category_product as catprod ON catprod.category_id = cat.entity_id
INNER JOIN catalog_product_entity as prod ON prod.entity_id = catprod.product_id
LEFT JOIN catalog_product_entity_decimal as prec on prec.entity_id = prod.entity_id
LEFT JOIN cataloginventory_stock_item AS stock ON stock.product_id = prod.entity_id
where children_count > 0 and cat1.attribute_id = 45 and cat.entity_id > 2
AND prec.value > $minPrice and prec.value < $maxPrice
group by cat.entity_id ";
$result = $connection->fetchAll($sql);
if($minPrice != "undefined" AND $maxPrice != "undefined" AND $minQty != "undefined" AND $maxQty != "undefined")
$sql = "SELECT cat.entity_id, cat1.value, count(prod.entity_id) AS totals FROM catalog_category_entity as cat
LEFT JOIN catalog_category_entity_varchar as cat1 ON cat.entity_id = cat1.entity_id
INNER JOIN catalog_category_product as catprod ON catprod.category_id = cat.entity_id
INNER JOIN catalog_product_entity as prod ON prod.entity_id = catprod.product_id
LEFT JOIN catalog_product_entity_decimal as prec on prec.entity_id = prod.entity_id
LEFT JOIN cataloginventory_stock_item AS stock ON stock.product_id = prod.entity_id
where children_count > 0 and cat1.attribute_id = 45 and cat.entity_id > 2
AND prec.value > $minPrice AND prec.value < $maxPrice
AND stock.qty > $minQty group by cat.entity_id";
$result = $connection->fetchAll($sql);
$sql = "SELECT cat.entity_id, cat1.value, count(prod.entity_id) AS totals FROM catalog_category_entity as cat
LEFT JOIN catalog_category_entity_varchar as cat1 ON cat.entity_id = cat1.entity_id
INNER JOIN catalog_category_product as catprod ON catprod.category_id = cat.entity_id
INNER JOIN catalog_product_entity as prod ON prod.entity_id = catprod.product_id
LEFT JOIN catalog_product_entity_decimal as prec on prec.entity_id = prod.entity_id
LEFT JOIN cataloginventory_stock_item AS stock ON stock.product_id = prod.entity_id
where children_count > 0 and cat1.attribute_id = 45 and cat.entity_id > 2 group by cat.entity_id";
$result = $connection->fetchAll($sql);
$resultJson = $this->_resultJsonFactory->create($result);
$collection = $resultJson->setData($result);
return $collection;
How I can return collection array json in a phtml file?
Thanks!!
magento2 product ajax filter
check this stackoverflow.com/questions/38220376/…
– magefms
2 days ago
add a comment |
Is it possible to return an array from a controller or from a block function to the phtml file?
<?php
namespace MnuhellFormSearchAttributesControllerIndex;
use MagentoFrameworkAppActionAction;
use MagentoFrameworkAppActionContext;
use MagentoFrameworkControllerResultJsonFactory;
use MagentoFrameworkRegistry;
use MagentoFrameworkViewResultPageFactory;
class Search extends Action
/**
* @var PageFactory
*/
protected $_resultPageFactory;
protected $_resultJsonFactory;
protected $_coreRegistry;
public function __construct(Context $context, PageFactory $resultPageFactory, JsonFactory $_resultJsonFactory, Registry $_coreRegistry)
$this->_resultPageFactory = $resultPageFactory;
$this->_resultJsonFactory = $_resultJsonFactory;
$this->_coreRegistry = $_coreRegistry;
parent::__construct($context);
public function execute()
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
$connection = $resource->getConnection();
$minPrice = $this->getRequest()->getParam('minPrice');
$maxPrice = $this->getRequest()->getParam('maxPrice');
$minQty = $this->getRequest()->getParam('minQty');
$maxQty = $this->getRequest()->getParam('maxQty');
//$category = $this->getRequest()->getParam('category');
if($minPrice != "undefined" AND $maxPrice != "undefined" AND $minQty == "undefined" AND $maxQty == "undefined")
$sql = "SELECT cat.entity_id, cat1.value, count(prod.entity_id) AS totals FROM catalog_category_entity as cat
LEFT JOIN catalog_category_entity_varchar as cat1 ON cat.entity_id = cat1.entity_id
INNER JOIN catalog_category_product as catprod ON catprod.category_id = cat.entity_id
INNER JOIN catalog_product_entity as prod ON prod.entity_id = catprod.product_id
LEFT JOIN catalog_product_entity_decimal as prec on prec.entity_id = prod.entity_id
LEFT JOIN cataloginventory_stock_item AS stock ON stock.product_id = prod.entity_id
where children_count > 0 and cat1.attribute_id = 45 and cat.entity_id > 2
AND prec.value > $minPrice and prec.value < $maxPrice
group by cat.entity_id ";
$result = $connection->fetchAll($sql);
if($minPrice != "undefined" AND $maxPrice != "undefined" AND $minQty != "undefined" AND $maxQty != "undefined")
$sql = "SELECT cat.entity_id, cat1.value, count(prod.entity_id) AS totals FROM catalog_category_entity as cat
LEFT JOIN catalog_category_entity_varchar as cat1 ON cat.entity_id = cat1.entity_id
INNER JOIN catalog_category_product as catprod ON catprod.category_id = cat.entity_id
INNER JOIN catalog_product_entity as prod ON prod.entity_id = catprod.product_id
LEFT JOIN catalog_product_entity_decimal as prec on prec.entity_id = prod.entity_id
LEFT JOIN cataloginventory_stock_item AS stock ON stock.product_id = prod.entity_id
where children_count > 0 and cat1.attribute_id = 45 and cat.entity_id > 2
AND prec.value > $minPrice AND prec.value < $maxPrice
AND stock.qty > $minQty group by cat.entity_id";
$result = $connection->fetchAll($sql);
$sql = "SELECT cat.entity_id, cat1.value, count(prod.entity_id) AS totals FROM catalog_category_entity as cat
LEFT JOIN catalog_category_entity_varchar as cat1 ON cat.entity_id = cat1.entity_id
INNER JOIN catalog_category_product as catprod ON catprod.category_id = cat.entity_id
INNER JOIN catalog_product_entity as prod ON prod.entity_id = catprod.product_id
LEFT JOIN catalog_product_entity_decimal as prec on prec.entity_id = prod.entity_id
LEFT JOIN cataloginventory_stock_item AS stock ON stock.product_id = prod.entity_id
where children_count > 0 and cat1.attribute_id = 45 and cat.entity_id > 2 group by cat.entity_id";
$result = $connection->fetchAll($sql);
$resultJson = $this->_resultJsonFactory->create($result);
$collection = $resultJson->setData($result);
return $collection;
How I can return collection array json in a phtml file?
Thanks!!
magento2 product ajax filter
Is it possible to return an array from a controller or from a block function to the phtml file?
<?php
namespace MnuhellFormSearchAttributesControllerIndex;
use MagentoFrameworkAppActionAction;
use MagentoFrameworkAppActionContext;
use MagentoFrameworkControllerResultJsonFactory;
use MagentoFrameworkRegistry;
use MagentoFrameworkViewResultPageFactory;
class Search extends Action
/**
* @var PageFactory
*/
protected $_resultPageFactory;
protected $_resultJsonFactory;
protected $_coreRegistry;
public function __construct(Context $context, PageFactory $resultPageFactory, JsonFactory $_resultJsonFactory, Registry $_coreRegistry)
$this->_resultPageFactory = $resultPageFactory;
$this->_resultJsonFactory = $_resultJsonFactory;
$this->_coreRegistry = $_coreRegistry;
parent::__construct($context);
public function execute()
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
$connection = $resource->getConnection();
$minPrice = $this->getRequest()->getParam('minPrice');
$maxPrice = $this->getRequest()->getParam('maxPrice');
$minQty = $this->getRequest()->getParam('minQty');
$maxQty = $this->getRequest()->getParam('maxQty');
//$category = $this->getRequest()->getParam('category');
if($minPrice != "undefined" AND $maxPrice != "undefined" AND $minQty == "undefined" AND $maxQty == "undefined")
$sql = "SELECT cat.entity_id, cat1.value, count(prod.entity_id) AS totals FROM catalog_category_entity as cat
LEFT JOIN catalog_category_entity_varchar as cat1 ON cat.entity_id = cat1.entity_id
INNER JOIN catalog_category_product as catprod ON catprod.category_id = cat.entity_id
INNER JOIN catalog_product_entity as prod ON prod.entity_id = catprod.product_id
LEFT JOIN catalog_product_entity_decimal as prec on prec.entity_id = prod.entity_id
LEFT JOIN cataloginventory_stock_item AS stock ON stock.product_id = prod.entity_id
where children_count > 0 and cat1.attribute_id = 45 and cat.entity_id > 2
AND prec.value > $minPrice and prec.value < $maxPrice
group by cat.entity_id ";
$result = $connection->fetchAll($sql);
if($minPrice != "undefined" AND $maxPrice != "undefined" AND $minQty != "undefined" AND $maxQty != "undefined")
$sql = "SELECT cat.entity_id, cat1.value, count(prod.entity_id) AS totals FROM catalog_category_entity as cat
LEFT JOIN catalog_category_entity_varchar as cat1 ON cat.entity_id = cat1.entity_id
INNER JOIN catalog_category_product as catprod ON catprod.category_id = cat.entity_id
INNER JOIN catalog_product_entity as prod ON prod.entity_id = catprod.product_id
LEFT JOIN catalog_product_entity_decimal as prec on prec.entity_id = prod.entity_id
LEFT JOIN cataloginventory_stock_item AS stock ON stock.product_id = prod.entity_id
where children_count > 0 and cat1.attribute_id = 45 and cat.entity_id > 2
AND prec.value > $minPrice AND prec.value < $maxPrice
AND stock.qty > $minQty group by cat.entity_id";
$result = $connection->fetchAll($sql);
$sql = "SELECT cat.entity_id, cat1.value, count(prod.entity_id) AS totals FROM catalog_category_entity as cat
LEFT JOIN catalog_category_entity_varchar as cat1 ON cat.entity_id = cat1.entity_id
INNER JOIN catalog_category_product as catprod ON catprod.category_id = cat.entity_id
INNER JOIN catalog_product_entity as prod ON prod.entity_id = catprod.product_id
LEFT JOIN catalog_product_entity_decimal as prec on prec.entity_id = prod.entity_id
LEFT JOIN cataloginventory_stock_item AS stock ON stock.product_id = prod.entity_id
where children_count > 0 and cat1.attribute_id = 45 and cat.entity_id > 2 group by cat.entity_id";
$result = $connection->fetchAll($sql);
$resultJson = $this->_resultJsonFactory->create($result);
$collection = $resultJson->setData($result);
return $collection;
How I can return collection array json in a phtml file?
Thanks!!
magento2 product ajax filter
magento2 product ajax filter
edited 2 days ago
magefms
3,0152629
3,0152629
asked May 6 at 4:52
manuelvillagrdomanuelvillagrdo
62
62
check this stackoverflow.com/questions/38220376/…
– magefms
2 days ago
add a comment |
check this stackoverflow.com/questions/38220376/…
– magefms
2 days ago
check this stackoverflow.com/questions/38220376/…
– magefms
2 days ago
check this stackoverflow.com/questions/38220376/…
– magefms
2 days ago
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f273470%2ffilter-product-with-ajax-and-return-json-array-from-a-controller-to-show-in-a-ph%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f273470%2ffilter-product-with-ajax-and-return-json-array-from-a-controller-to-show-in-a-ph%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
check this stackoverflow.com/questions/38220376/…
– magefms
2 days ago