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
Can the president of the United States be guilty of insider trading?
Does Thread.yield() do anything if we have enough processors to service all threads?
Why is it wrong to *implement* myself a known, published, widely believed to be secure crypto algorithm?
When do you stop "pushing" a book?
Names of the Six Tastes
Passport stamps art, can it be done?
How can I make parentheses stick to formula?
What dice to use in a game that revolves around triangles?
What are these round pads on the bottom of a PCB?
Does STATISTICS IO output include Version Store reads?
How to avoid making self and former employee look bad when reporting on fixing former employee's work?
Two (probably) equal real numbers which are not proved to be equal?
Is there an idiom that means "revealing a secret unintentionally"?
Company stopped paying my salary. What are my options?
What does the "DS" in "DS-..." US visa application forms stand for?
How can it be that ssh somename works, while nslookup somename does not?
Why are thrust reversers not used to slow down to taxi speeds?
Publishing an article in a journal without a related degree
if i accidentally leaked my schools ip address and someone d doses my school am i at fault
Has everyone forgotten about wildfire?
Are wands in any sort of book going to be too much like Harry Potter?
Is there an application which does HTTP PUT?
How did Captain Marvel know where to find these characters?
Why use steam instead of just hot air?
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