AppInsights - How to set log category - appinsights

I am using following code to send logs of all categories to AppInsight.
services.AddLogging(loggingBuilder => loggingBuilder.AddFilter<Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider>("", LogLevel.Trace));
But I do not understand where and how do I define a log category.
What is this category?

Related

How to get all information from a related collection in strapi v4?

I have created a collection (favorite) related to product and user.
My product collection has a field called images but when i make a GET request to favorites i dont get back the images. I have all permissions active for users. This is my query
http://192.168.0.102:1337/api/favorites?populate=product&filters[user][id][$eq]=4.
I am following: https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/filtering-locale-publication.html#filtering
Images are also considered to be 'relations' on a collection. You need explicitly tell it to populate those, see populating two levels: https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/populating-fields.html#relation-media-fields

Don't show the message to all users? ( laravel )

I need to create to send a message to all new users registered on my website. I created a table called messages that admins can store (insert) the messages from the admin panel to this table and these messages are simply shown to all users with a foreach.
I don't know if this the best way to do something like that!
Anyway, the problem is that when any new user register and open his dashboard he just found the old messages
This is the table :
image
And this is the simple code for foreach
$msgForAll = Message::latest()->get();
I'm not sure how to display new messages to the users.
Again the way I made this idea is wrong, I know that ):
You can use eloquent's where spefically the whereDate queries in your case to get certain rows past or before date.
As an example relating to what you want to do, it can be along the lines of this:
// Given that you are using Auth to get the user's data...
// Get messages that were created after the user's creation date
$messages = Message::whereDate('created_at','>',Auth::User()->created_at)->get();

magento soap api to get all product details with filter php

I'm using magento 1.9.1 and I have to show my products on other website for that need api which give me list of all enable products with following details
product id
sku
name
description
short description
stock
price
tax
category
So I need to call multiple magento api's, Is it possible in on api call?
Also I want products form specific category so filter is also needed
I have tried
$filter = array(
'category_ids' => '59'
);
$result = $client->call($session, 'catalog_product.list',$filter);
But it gives list of all product

product show in stock in admin order when it is in out of stock Magento

Hi i am trapped in a very strange situation, my client has enable the customers to order the products which are out of stock , the problem is when the customer place the order it shows the product in stock in order . I need to show the product status out of stock in the order so he come to know about the order item status .
Below is the settings i have in catalog-> inventory in admin
please suggest me where i am doing mistake or how can i do this
thanks
You need to modify your product.phtml inside app/design/frontend/{yourpackage}/{yourtheme}/template/catalog/product/view.phtml
Add following in your code scope for testing and checking if its not already showing out of stock .
$stockItem = Mage::getModel('cataloginventory/stock_item');
$resource = $stockItem->loadByProduct($_product->getId());
if(round($resource->getQty(),0) < 1)
{
echo "product is out of stock";
}
The above code actually tests if there is any quantity available in stock and is greater than 1. Also make a note that this will not work for the products setup as not to be managed by stock under inventory tab in product add/modify case.
Thanks

in magento how can i Get related product in the product listing page

I am doing a magento project where i have to bring related product and upsell product in the product listing page which is product/list.phtml
i can get all the product details from
foreach ($_productCollection as $_product):
$_product->
but i can't get any related product and upsell product using $_product->
please help me please
You can do the following (inside the foreach loop)
$related_product_collection = $_product->getRelatedProductCollection();
$related_product_collection->AddStoreFilter();
Regards,
Kenny
PS: If you want to know which methods are available, you can always run the
var_dump(get_class_methods($_product)); die;
//or
Mage::log(print_r(get_class_methods($_product),true));
First one will print all available methods on the screen while second one will output it in the system.log located in the /var/log/system.log (make sure that in configuration->developer you have logging enabled of course)
You can pass product id for which you require related product.
E.g
You need related product for a particular product (Say $_product)
You can get related product ids by
$_product->getRelatedProductIds()
You can see array of ids by :
print_r($_product->getRelatedProductIds());
I hope this will help you.
Regards,
Kamesh J
On list page you get all product details with id.
using this code $_product=Mage::getModel('catalog/product')->load(product_id);
you get product for that id.
After use this code to get details of related product
$relatedProductsId=$_product->getRelatedProductIds();
$relatedProducts=array();
$i=0;
foreach($relatedProductsId as $relatedProductId)
{
$relatedProducts[$i] = Mage::getModel('catalog/product')->load($relatedProductId)->getName();
$i++;
}
and you get all related product

Resources