Get Top Rated Products and Order by rating The Next CEO of Stack OverflowHow to add more attributes to product collectionJoin table to product/catalog collection to display new custom column in catalog grid`getLastPageNumber()` returning wrong number of pagesCan't get “products ordered” collection with configurable products included (top 10 products)Programatically get product rating and review in magento 2 product collectionMagento 2 How to get product collection of all products?Problem creating part numbersMagento more than 61 product attribute database tables in join queryHow to add .5 rating for products magento?Custom Customer attribute grid not filter by asc or dec
Do I need to write [sic] when including a quotation with a number less than 10 that isn't written out?
Man transported from Alternate World into ours by a Neutrino Detector
How to compactly explain secondary and tertiary characters without resorting to stereotypes?
Creating a script with console commands
Arrows in tikz Markov chain diagram overlap
Masking layers by a vector polygon layer in QGIS
Ising model simulation
Is it possible to make a 9x9 table fit within the default margins?
Salesforce opportunity stages
How to unfasten electrical subpanel attached with ramset
Is a linearly independent set whose span is dense a Schauder basis?
Incomplete cube
Avoiding the "not like other girls" trope?
Free fall ellipse or parabola?
Can a PhD from a non-TU9 German university become a professor in a TU9 university?
How dangerous is XSS
Calculate the Mean mean of two numbers
Finitely generated matrix groups whose eigenvalues are all algebraic
Another proof that dividing by 0 does not exist -- is it right?
How can a day be of 24 hours?
Are British MPs missing the point, with these 'Indicative Votes'?
Strange use of "whether ... than ..." in official text
Direct Implications Between USA and UK in Event of No-Deal Brexit
My boss doesn't want me to have a side project
Get Top Rated Products and Order by rating
The Next CEO of Stack OverflowHow to add more attributes to product collectionJoin table to product/catalog collection to display new custom column in catalog grid`getLastPageNumber()` returning wrong number of pagesCan't get “products ordered” collection with configurable products included (top 10 products)Programatically get product rating and review in magento 2 product collectionMagento 2 How to get product collection of all products?Problem creating part numbersMagento more than 61 product attribute database tables in join queryHow to add .5 rating for products magento?Custom Customer attribute grid not filter by asc or dec
I want to get Top Rated Products collection and sort it by ratings. I'm using the code but not working.
$collection->getSelect()->joinLeft(
'rating_option_vote_aggregated',
'e.entity_id = rating_option_vote_aggregated.entity_pk_value',
array('vote_count' => 'SUM(rating_option_vote_aggregated.vote_count)'))
->group('e.entity_id')
->order('vote_count ' . $this->getCurrentDirectionReverse());
[2019-04-01 12:51:58] main.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'vote_count ' in 'order clause', query was: SELECT
e
.*,price_index
.price
,price_index
.tax_class_id
,price_index
.final_price
, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) ASminimal_price
,price_index
.min_price
,price_index
.max_price
,price_index
.tier_price
, IF(at_status.value_id > 0, at_status.value, at_status_default.value) ASstatus
, IF(at_visibility.value_id > 0, at_visibility.value, at_visibility_default.value) ASvisibility
, SUM(rating_option_vote_aggregated.vote_count) ASvote_count
,stock_status_index
.stock_status
ASis_salable
FROMcatalog_product_entity
ASe
INNER JOINcatalog_product_index_price
ASprice_index
ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0
INNER JOINcatalog_product_entity_int
ASat_status_default
ON (at_status_default
.entity_id
=e
.entity_id
) AND (at_status_default
.attribute_id
= '97') ANDat_status_default
.store_id
= 0
LEFT JOINcatalog_product_entity_int
ASat_status
ON (at_status
.entity_id
=e
.entity_id
) AND (at_status
.attribute_id
= '97') AND (at_status
.store_id
= 1)
INNER JOINcatalog_product_entity_int
ASat_visibility_default
ON (at_visibility_default
.entity_id
=e
.entity_id
) AND (at_visibility_default
.attribute_id
= '99') ANDat_visibility_default
.store_id
= 0
LEFT JOINcatalog_product_entity_int
ASat_visibility
ON (at_visibility
.entity_id
=e
.entity_id
) AND (at_visibility
.attribute_id
= '99') AND (at_visibility
.store_id
= 1)
LEFT JOINrating_option_vote_aggregated
ON e.entity_id = rating_option_vote_aggregated.entity_pk_value
INNER JOINcataloginventory_stock_status
ASstock_status_index
ON e.entity_id = stock_status_index.product_id AND stock_status_index.website_id = 0 AND stock_status_index.stock_id = 1 WHERE (IF(at_status.value_id > 0, at_status.value, at_status_default.value) = '1') AND (IF(at_visibility.value_id > 0, at_visibility.value, at_visibility_default.value) = '4') AND (stock_status_index.stock_status = 1) GROUP BYe
.entity_id
ORDER BYvote_count
ASC
LIMIT 8 [] []
magento2.2 product-collection
add a comment |
I want to get Top Rated Products collection and sort it by ratings. I'm using the code but not working.
$collection->getSelect()->joinLeft(
'rating_option_vote_aggregated',
'e.entity_id = rating_option_vote_aggregated.entity_pk_value',
array('vote_count' => 'SUM(rating_option_vote_aggregated.vote_count)'))
->group('e.entity_id')
->order('vote_count ' . $this->getCurrentDirectionReverse());
[2019-04-01 12:51:58] main.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'vote_count ' in 'order clause', query was: SELECT
e
.*,price_index
.price
,price_index
.tax_class_id
,price_index
.final_price
, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) ASminimal_price
,price_index
.min_price
,price_index
.max_price
,price_index
.tier_price
, IF(at_status.value_id > 0, at_status.value, at_status_default.value) ASstatus
, IF(at_visibility.value_id > 0, at_visibility.value, at_visibility_default.value) ASvisibility
, SUM(rating_option_vote_aggregated.vote_count) ASvote_count
,stock_status_index
.stock_status
ASis_salable
FROMcatalog_product_entity
ASe
INNER JOINcatalog_product_index_price
ASprice_index
ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0
INNER JOINcatalog_product_entity_int
ASat_status_default
ON (at_status_default
.entity_id
=e
.entity_id
) AND (at_status_default
.attribute_id
= '97') ANDat_status_default
.store_id
= 0
LEFT JOINcatalog_product_entity_int
ASat_status
ON (at_status
.entity_id
=e
.entity_id
) AND (at_status
.attribute_id
= '97') AND (at_status
.store_id
= 1)
INNER JOINcatalog_product_entity_int
ASat_visibility_default
ON (at_visibility_default
.entity_id
=e
.entity_id
) AND (at_visibility_default
.attribute_id
= '99') ANDat_visibility_default
.store_id
= 0
LEFT JOINcatalog_product_entity_int
ASat_visibility
ON (at_visibility
.entity_id
=e
.entity_id
) AND (at_visibility
.attribute_id
= '99') AND (at_visibility
.store_id
= 1)
LEFT JOINrating_option_vote_aggregated
ON e.entity_id = rating_option_vote_aggregated.entity_pk_value
INNER JOINcataloginventory_stock_status
ASstock_status_index
ON e.entity_id = stock_status_index.product_id AND stock_status_index.website_id = 0 AND stock_status_index.stock_id = 1 WHERE (IF(at_status.value_id > 0, at_status.value, at_status_default.value) = '1') AND (IF(at_visibility.value_id > 0, at_visibility.value, at_visibility_default.value) = '4') AND (stock_status_index.stock_status = 1) GROUP BYe
.entity_id
ORDER BYvote_count
ASC
LIMIT 8 [] []
magento2.2 product-collection
add a comment |
I want to get Top Rated Products collection and sort it by ratings. I'm using the code but not working.
$collection->getSelect()->joinLeft(
'rating_option_vote_aggregated',
'e.entity_id = rating_option_vote_aggregated.entity_pk_value',
array('vote_count' => 'SUM(rating_option_vote_aggregated.vote_count)'))
->group('e.entity_id')
->order('vote_count ' . $this->getCurrentDirectionReverse());
[2019-04-01 12:51:58] main.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'vote_count ' in 'order clause', query was: SELECT
e
.*,price_index
.price
,price_index
.tax_class_id
,price_index
.final_price
, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) ASminimal_price
,price_index
.min_price
,price_index
.max_price
,price_index
.tier_price
, IF(at_status.value_id > 0, at_status.value, at_status_default.value) ASstatus
, IF(at_visibility.value_id > 0, at_visibility.value, at_visibility_default.value) ASvisibility
, SUM(rating_option_vote_aggregated.vote_count) ASvote_count
,stock_status_index
.stock_status
ASis_salable
FROMcatalog_product_entity
ASe
INNER JOINcatalog_product_index_price
ASprice_index
ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0
INNER JOINcatalog_product_entity_int
ASat_status_default
ON (at_status_default
.entity_id
=e
.entity_id
) AND (at_status_default
.attribute_id
= '97') ANDat_status_default
.store_id
= 0
LEFT JOINcatalog_product_entity_int
ASat_status
ON (at_status
.entity_id
=e
.entity_id
) AND (at_status
.attribute_id
= '97') AND (at_status
.store_id
= 1)
INNER JOINcatalog_product_entity_int
ASat_visibility_default
ON (at_visibility_default
.entity_id
=e
.entity_id
) AND (at_visibility_default
.attribute_id
= '99') ANDat_visibility_default
.store_id
= 0
LEFT JOINcatalog_product_entity_int
ASat_visibility
ON (at_visibility
.entity_id
=e
.entity_id
) AND (at_visibility
.attribute_id
= '99') AND (at_visibility
.store_id
= 1)
LEFT JOINrating_option_vote_aggregated
ON e.entity_id = rating_option_vote_aggregated.entity_pk_value
INNER JOINcataloginventory_stock_status
ASstock_status_index
ON e.entity_id = stock_status_index.product_id AND stock_status_index.website_id = 0 AND stock_status_index.stock_id = 1 WHERE (IF(at_status.value_id > 0, at_status.value, at_status_default.value) = '1') AND (IF(at_visibility.value_id > 0, at_visibility.value, at_visibility_default.value) = '4') AND (stock_status_index.stock_status = 1) GROUP BYe
.entity_id
ORDER BYvote_count
ASC
LIMIT 8 [] []
magento2.2 product-collection
I want to get Top Rated Products collection and sort it by ratings. I'm using the code but not working.
$collection->getSelect()->joinLeft(
'rating_option_vote_aggregated',
'e.entity_id = rating_option_vote_aggregated.entity_pk_value',
array('vote_count' => 'SUM(rating_option_vote_aggregated.vote_count)'))
->group('e.entity_id')
->order('vote_count ' . $this->getCurrentDirectionReverse());
[2019-04-01 12:51:58] main.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'vote_count ' in 'order clause', query was: SELECT
e
.*,price_index
.price
,price_index
.tax_class_id
,price_index
.final_price
, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) ASminimal_price
,price_index
.min_price
,price_index
.max_price
,price_index
.tier_price
, IF(at_status.value_id > 0, at_status.value, at_status_default.value) ASstatus
, IF(at_visibility.value_id > 0, at_visibility.value, at_visibility_default.value) ASvisibility
, SUM(rating_option_vote_aggregated.vote_count) ASvote_count
,stock_status_index
.stock_status
ASis_salable
FROMcatalog_product_entity
ASe
INNER JOINcatalog_product_index_price
ASprice_index
ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0
INNER JOINcatalog_product_entity_int
ASat_status_default
ON (at_status_default
.entity_id
=e
.entity_id
) AND (at_status_default
.attribute_id
= '97') ANDat_status_default
.store_id
= 0
LEFT JOINcatalog_product_entity_int
ASat_status
ON (at_status
.entity_id
=e
.entity_id
) AND (at_status
.attribute_id
= '97') AND (at_status
.store_id
= 1)
INNER JOINcatalog_product_entity_int
ASat_visibility_default
ON (at_visibility_default
.entity_id
=e
.entity_id
) AND (at_visibility_default
.attribute_id
= '99') ANDat_visibility_default
.store_id
= 0
LEFT JOINcatalog_product_entity_int
ASat_visibility
ON (at_visibility
.entity_id
=e
.entity_id
) AND (at_visibility
.attribute_id
= '99') AND (at_visibility
.store_id
= 1)
LEFT JOINrating_option_vote_aggregated
ON e.entity_id = rating_option_vote_aggregated.entity_pk_value
INNER JOINcataloginventory_stock_status
ASstock_status_index
ON e.entity_id = stock_status_index.product_id AND stock_status_index.website_id = 0 AND stock_status_index.stock_id = 1 WHERE (IF(at_status.value_id > 0, at_status.value, at_status_default.value) = '1') AND (IF(at_visibility.value_id > 0, at_visibility.value, at_visibility_default.value) = '4') AND (stock_status_index.stock_status = 1) GROUP BYe
.entity_id
ORDER BYvote_count
ASC
LIMIT 8 [] []
magento2.2 product-collection
magento2.2 product-collection
edited 14 hours ago
Magecode
asked 14 hours ago
MagecodeMagecode
539421
539421
add a comment |
add a comment |
0
active
oldest
votes
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%2f268207%2fget-top-rated-products-and-order-by-rating%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%2f268207%2fget-top-rated-products-and-order-by-rating%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