Get Top Rated Products and Order by ratingHow 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
Am I breaking OOP practice with this architecture?
What method can I use to design a dungeon difficult enough that the PCs can't make it through without killing them?
CAST throwing error when run in stored procedure but not when run as raw query
What killed these X2 caps?
Is there an expression that means doing something right before you will need it rather than doing it in case you might need it?
Detention in 1997
How to show a landlord what we have in savings?
Apex Framework / library for consuming REST services
Do scales need to be in alphabetical order?
How to tell a function to use the default argument values?
How do conventional missiles fly?
Can I run a new neutral wire to repair a broken circuit?
Plagiarism or not?
Why is this clock signal connected to a capacitor to gnd?
Avoiding direct proof while writing proof by induction
Is "remove commented out code" correct English?
Gatling : Performance testing tool
Would Slavery Reparations be considered Bills of Attainder and hence Illegal?
Is it acceptable for a professor to tell male students to not think that they are smarter than female students?
Examples of smooth manifolds admitting inbetween one and a continuum of complex structures
How do I know where to place holes on an instrument?
Could the museum Saturn V's be refitted for one more flight?
How would I stat a creature to be immune to everything but the Magic Missile spell? (just for fun)
How to compactly explain secondary and tertiary characters without resorting to stereotypes?
Get Top Rated Products and Order by rating
How 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 2 days ago
Magecode
asked 2 days ago
MagecodeMagecode
544421
544421
add a comment |
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%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