product not showing on cateogry page after migration from Magento 2.2.4 to Magento 2.4.0 - magento2

I have updated Magento 2.2.4 to Magento 2.4.0. After that products are not showing on category page. please note when i search products were showing and also product details page is opening.
Please see the screenshot:
I have tried indexing , creating inventory view, tried creating new product and category, stock is also fine, product also assigned to website. Elastic search also configured as required .
I also tried to print to print the collection query on ListProduct.php
and I get this
"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) AS `minimal_price`, `price_index`.`min_price`, `price_index`.`max_price`, `price_index`.`tier_price`, IFNULL(review_summary.reviews_count, 0) AS `reviews_count`, IFNULL(review_summary.rating_summary, 0) AS `rating_summary`, `stock_status_index`.`stock_status` AS `is_salable` FROM `catalog_product_entity` AS `e` INNER JOIN `catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id AND price_index.customer_group_id = 0 AND price_index.website_id = '1' LEFT JOIN `review_entity_summary` AS `review_summary` ON e.entity_id = review_summary.entity_pk_value AND review_summary.store_id = 1 AND review_summary.entity_type = (SELECT `review_entity`.`entity_id` FROM `review_entity` WHERE (entity_code = 'product')) INNER JOIN `cataloginventory_stock_status` AS `stock_status_index` ON e.entity_id = stock_status_index.product_id WHERE (NULL)"

I had the same problem you described, tried the same steps you outlined, tracked down the same collection query. Ultimately the cause was a product attribute added by a third-party extension, said attribute was improperly configured.
Try the resolution explained here — https://magento.stackexchange.com/a/322623/36384

Related

Magento 2 Getting an error "The requested qty exceeds the maximum qty allowed in shopping cart."

code example:
class CustomAddToCart {
public function __construct(
\Magento\Checkout\Model\Cart $cart
) {
$this->cart = $cart;
}
public function execute()
{
$product = ....
$this->cart->addProduct($product, ['product' => $product->getId(), 'qty' => 1]);
$this->cart->save();
}
}
When the cart do the save Magento tries to change the quantity of the last item currently in the cart into 2. Since all products in our website only have a stock quantity of 1 it can only be added in the cart once. So I do not know why Magento is doing this. Can anybody please help me if someone already had experience this.
xdebug break point where last item in cart is increased from 1 to 2
xdebug call stack trace of the trace
I hope you are doing great!
Please check below configuration which is global for all the products.
1. Stores > Configuration > Catalog > Inventory > Product Stock Options > Maximum Qty Allowed in Shopping Cart
Secondly, you need to check the below configuration of the product for which the quantity is changing. This setting will take the precedence on global setting so please do the product related changes with the help of below setting and try one more time.
2. Catalog > Products > Edit the product which is having a problem while adding to the cart > Search for "Advanced Inventory" and click on it you will get Maximum Qty Allowed in Shopping Cart and change it to 1 (It can be anything)
3. Don't forget to clear the cache.
Please take a look at the below link.
https://github.com/magento/magento2/issues/18477
Thanks,
Sonu

Issue with the join expression in Access 2013

Given below is the sample of my code. When I tried to switch to the design view it gives me an error:
"Microsoft Access can't represent the join expression a.Course_name=b.Course_name in Design view".
When I searched this error on stackoverflow I found one post. According to the post the solution is given in this link (http://support.microsoft.com/kb/207868). According to this link, try to remove extra parenthesis (especially nested parenthesis) and problem will be resolved. However, in my query I don't have nested parenthesis. So I don't know how to fix it. Any help would be appreciated.
SELECT a.Course_name, COUNT(b.Student_code) AS [Total], Format(b.Retrieved_date,"mmmm yyyy") AS [Month]
FROM Course AS a LEFT JOIN (SELECT b.Course_name, b.Student_code, b.Retrieved_date FROM pending-enrolment AS b WHERE b.Retrieved_date BETWEEN [Forms]![ParameterForm]![txtBeginDate] AND [Forms]![ParameterForm]![txtEndDate]) b
ON a.Course_name=b.Course_name
GROUP BY a.Course_name, b.Retrieved_date
;
Try the following code (tested and works 100%):
SELECT Course.Course_name, Count(b.Student_code) AS CountOfStudent_code,
Format([b].[Retrieved_date],"mmmm yyyy") AS [Month]
FROM Course
LEFT JOIN
(
SELECT [pending-enrolment].Course_name, [pending-enrolment].Student_code,
[pending-enrolment].Retrieved_date
FROM [pending-enrolment]
WHERE ([pending-enrolment].Retrieved_date
Between [Forms]![ParameterForm]![txtBeginDate]
And [Forms]![ParameterForm]![txtEndDate])
) AS b ON Course.Course_name = b.Course_name
GROUP BY Course.Course_name, Format([b].[Retrieved_date],"mmmm yyyy");

How can I display count of imagefield images in views?

I want to display the number of images uploaded to an imagefield, in a views field or views tpl.php. How can I do this? My imagefield is called boatimages. I tried this but it comes out as 0, not the correct number: < ? php print count($fields->field_boatimages) ?>
Ack. I do not think count() works like that.
Why not just do this using Views? Take a look at Arguments > Settings and you'll see 'display record count' which seems like all you would need for this.
My suggestion is install the devel module and use the function dpm to print the variable if you wanna know the structure (print_r() may work too). If count isn't working it's because, you are probably using it with the wrong data.
OR, you could just query the database for the field. I'm gonna provide you instructions for drupal 7 but drupal 6 should be similar.
Check the table field_data_field_boatimages. See how there's a list of your images related with a single entity_id
Then execute this query
SELECT COUNT(*) FROM `field_data_field_boatimages` WHERE entity_id = ###
Where ### is the entity_id you want to know. You can get it by looking for arg(1) if arg(0) == node in your page.
Now you just have to use php power to print thar result
$query = SELECT COUNT(*) FROM `field_data_field_boatimages` WHERE entity_id = :eid
$result = db_query($query, array(':eid', $nid))->fetchField();
echo $result;
Drupal 6 would be very similar. Just a little difference in the table names and the query syntax. For example using db_result instead of fetchField()
Anyway good luck!

wordpress 3.2.1 database query

i am trying to make a simple selection in a wordpress table (created by a plugin). the table is named reduceri , and has the following columns: id, post, category.
so, i am trying to take all the category values, when the post is equal to the current post id.
the way i am doing the query is:
$the_query = "
SELECT $wpdb->reduceri.category
FROM $wpdb->reduceri
WHERE $wpdb->reduceri.post = ".$post_id."
";
$my_reduceri = $wpdb->get_results($the_query);
but when i var_dump the $my_reduceri all i get is an empty array: array(0) { } even though there should actually be some results... any idea where i am wrong (in the query)?
thank you
Did you declared global $wpdb; before using this query?

Eager loading in Entity Framework fails on complex query

The following query fails to load the tables when I execute it:
IEnumerable<Bookmark> tempBookmarks = ListBookmarksByUserID(userID);
IEnumerable<CandidateWithBookmarks> results = (from c in _internshipEntities.CandidateSet
.Include("education")
.Include("progress")
.Include("contacts")
.Include("availability")
.Include("hosttypes")
.Include("hostsizes")
.Include("hostcapacities")
.Include("hoststates")
.Include("users")
join b in tempBookmarks on c.ID equals b.candidates.ID
select new CandidateWithBookmarks()
{CandidateObject = c, BookmarkObject = b});
return results;
I have found some articles related to the problem, namely Alex James' article "How to make Include really Include". The solution comes with one caveat:
For this to work your final select must be entities, i.e. select post rather than select new {…}
Which is obviously an issue for the above block of code. Are there any other known work-arounds for this issue that won't break eager loading?
I think I solved this but it might only work for this specific instance, by moving the includes after the join, the query appears to work:
IEnumerable<CandidateWithBookmarks> results = (
from b in tempBookmarks
join c in _internshipEntities.CandidateSet
.Include("education")
.Include("progress")
.Include("contacts")
.Include("availability")
.Include("hosttypes")
.Include("hostsizes")
.Include("hostcapacities")
.Include("hoststates")
.Include("users")
on b.candidates.ID equals c.ID
select new CandidateWithBookmarks(){CandidateObject = c, BookmarkObject = b});
Edit: Another query I have similar to this requires an outer join as well, which creates some issues since it then matters what you join to what, unlike this example, but it's still doable.