Empty product list for guest requests - rest

I am trying to read Magento product list via REST API using guest account. My Magento instance responds to GET /api/rest/products/1 as expected, with:
<?xml version="1.0"?>
<magento_api>
<entity_id>1</entity_id>
<type_id>simple</type_id>
<sku>simple_sku</sku>
<name>simple</name>
<meta_title/>
<meta_description/>
<description>description</description>
<short_description>short description</short_description>
<meta_keyword/>
<tier_price/>
<is_in_stock>0</is_in_stock>
<regular_price_with_tax>100</regular_price_with_tax>
<regular_price_without_tax>100</regular_price_without_tax>
<final_price_with_tax>100</final_price_with_tax>
<final_price_without_tax>100</final_price_without_tax>
<is_saleable>0</is_saleable>
<image_url>http://localhost/media/catalog/product/cache/0/image/9df78eab33525d08d6e5fb8d27136e95/images/catalog/product/placeholder/image.jpg</image_url>
<url>http://localhost/index.php/catalog/product/view/id/1/s/simple/</url>
<buy_now_url>http://localhost/index.php/checkout/cart/add/uenc/aHR0cDovL2xvY2FsaG9zdC9hcGkvcmVzdC9wcm9kdWN0cy8x/product/1/form_key/6DQ0mBsIua4HpuGN/</buy_now_url>
<total_reviews_count>0</total_reviews_count>
<has_custom_options/>
</magento_api>
However, asking the same Magento instance for a list of products using GET /api/rest/products returns empty result, when I would expect a list containing that product:
<?xml version="1.0"?>
<magento_api/>
The result is populated correctly when calling as oauth authenticated user, but I need it working for guest account.
Guest REST role has been configured to get "All" resource access and "All" attributes. I have this behaviour for Magento versions 1.9.0.1 and 1.9.1.0, for both formats: xml and json, (json returning []). Also changing "All" guest settings to manually selected checkboxes didn't solve this issue.

Thanks to this blog post, I found out that Magento doesn't show out of stock products for guest role in REST API. To change this behaviour, edit setting System > Configuration > Catalog > Inventory > Stock options > Display out of stock products
Reason for that behaviour could be, that guests shouldn't see unavailable products because they cannot order or do anything with them. At the same time admin can see them, because they are potentially edible for him (if admin role has been granted that permission).

Related

Preventing user from modifying their name in Keycloak

In Keycloak, by default, users are able to change their first and last name in the account manager page. However, is it possible to disable this behavior?
Removing both fields in the theme results in those values not being sent and the form failing, and a hand-crafted POST request would defeat this method anyway.
I came across a similar problem and after reading this SO post, came to know that although you can disable/hide fields in ftl, you cannot disable form validation
For e.g I hid firstname field , but still cannot submit. Same was the result with disable as well:
I am not aware about disabling a particular field in some other way. However there is a workaround in which you can disable the entire account modification flow (Password can still be changed by Forgot Password option).
Bu default, account modification is enabled, but you can disable it for a particular realm by going to Realms -> Clients -> Account.
The result of this will be, the account page will be inaccessible:
You can remove the client role 'manage_account' for client 'account'.
In Keycloak, by default, users are able to change their first and last
name in the account manager page. Is it possible to disable this
behavior?
That can be done out-of-the-box (since Keycloak 14) by using the user profile functionality. First, the preview feature declarative-user-profile has to be enabled. For that start the server with:
--features=declarative-user-profile.
for the Quarkus version, or with
-Dkeycloak.profile.feature.declarative_user_profile=enabled
for the Wildfly version.
Bear in mind that:
Declarative User Profile is Technology Preview and is not fully
supported.
After starting the server with the aforementioned option, go to the Keycloak Admin Console and:
Go to the according Realm;
Go to the tab General;
Set User Profile enabled to ON
A new tab named User Profile (top right) will show up; click on it, and a set of configurable attributes will be shown.
Click on firstName, and then go to Permissions
In that section the permissions can be changed, accordingly. For example, if one sets Can user edit? to OFF, then when the user tries to change the firstName field in the account UI, that UI throws the following warning message:
The field First name is read only.
The same configuration can also be applied to the lastName attribute.
For the new Keycloak UI the workflow is exactly the same as the one I have just described. More information about the feature can be found in the official keycloak documentation (link)
You can use readonly property to disable email you can just change the following line:
<input type="text" class="form-control" id="email" name="email" readonly autofocus value="${(account.email!'')}"/>

Access Keycloak group attributes from Nodejs

I've got Keycloak setup and running with NodeJS.
I see you can create groups and assign attributes to those groups. Is it possible to access these attributes from the NodeJS application?
I can't even find the groups let alone their attributes.
Yes you can. But there is almost no official documentation on how to achieve this. You can return most keycloak attributes, groups and roles through the client mappers. By default none are configured.
To configure extra mappers: In the administration console, select the client and then the Mappers tab. That should bring you to a list of mappers.
You can add mappers here of different types. Once you add a mapper you can decide which calls to Keycloak from the client return the attribute(s), and what the name of the returned attribute is. The following screenshot includes a mapper that returns a dictionary of groups, with subgroups, separated by forward slashes. Your Node code will need to parse the returned JSON object.
All the information is returned in the keycloak token, which is a Javascript Web Token. In Node you can examine it by printing the token to the log. The keycloak-connect middleware stores tokens etc in an object on the request called kauth. The path to retrieve a list of groups specified by the configuration in the above screenshot is shown below. If you change the token claim name in the configuration, you will need to change the path in your NodeJS code accordingly. You will need to logout from your application and login again for changes to the mapper to work.
router.get('/', async function(req, res){
console.log(req.kauth.grant.access_token.content.groups) ..
}

SuiteCommerce Advance: Unable to get the Free Shipping Rule Rate 'Insufficient permissions' for Custom Service

We tried loading shipping item data with 'nlapiLoadRecord', Currently we have two methods available Standard & Express. We tried to load data for standard method as below in Script Debugger.
​var standard = nlapiLoadRecord('shipitem',3);
We are getting all fields of standard shipitem in Script Debugger, then we are fetching shipping rule value with
var standard_amount = standard.getFieldValues('freeifordertotalisoveramount');
Then we tried to load these same data using nlapiLoadRecord in our custom SuiteScript Model, we tried to call this method in our custom ShippingDetails.Model, and tried to fetched the data on cart page but it is giving us 'Insufficient permissions' error massage. Please see below attached screenshot. nlapiLoadRecord('shipitem',3); does not allow us to load data on front end.
Basically this is not case with your code, as you are trying to load shipping rate using SuiteScript Service and model this is perfect.
​var standard = nlapiLoadRecord('shipitem',3);
var standard_amount = standard.getFieldValues('freeifordertotalisoveramount');
This is completely related with user's permission i.e Roles Under Setup-->User/Roles-->Manage Roles you are trying to fetch data of 'shippingitem' in this case you must need to check different permission
Check your Script Service is enabled, enabled for with out login in NS back end
Most Imp:
2. Check shipping item is added in permission under List i.e the role which you are using for Service, for that role you must need to set shipping item See below screen shot you will get more idea.

github users API Paging not work

when using github users api to return users data through
https://api.github.com/users?page=6&per_page=2
return the same data every one although change page parameter value and per_page
why this and how to fix to change different data
i try to edit header request and add this header
Name Link
Value <https://api.github.com/users?page=1&per_page=2>; rel="next",<https://api.github.com/users?page=50&per_page=2>; rel="last"
But Still not working
After my search
now Github use API V3 and if you want return users with paging you can use this
https://api.github.com/users?since=1&per_page=100
Instead of using "page" and "per_page", that endpoint uses "since" and "per_page".
The since parameter says from which user ID the API should start listing users. For example:
https://api.github.com/users?since=1&per_page=100
will start listing users from the user with ID 1, and
https://api.github.com/users?since=10001&per_page=100
will start listing users from the user with ID 10001.

Drupal email users

I'm using Drupal 6.16: When a user creates an account on my site I have them select a category (ie children, youth, adult, etc). This is done with the select list box using the content_profile module. I have a content type that posts an announcement. In this content type is a check box that says 'email group'. Right now it does nothing, but what I would like for it to do is e-mail all the users that are associated with the group they chose when signing up for their account. If this will require extra code please be specific as I am not a strong php programmer.
Thanks for the help!!
msindle
There might be some module that do it exactly, but I don't think so.
I would have done it using few building blocks:
Retrieve the list of emails using Views - define a view that gives you the addresses according to a given group argument.
Use Rules module that will send an email notification after node is created.
Combine the two (this is the hard part) - insert the values from the view as the recipients for the email. You might be able to do it using PHP inside the Rule definition, plus view execution.
Try to accomplish it, and if you get into troubles, you are welcome to contact me via shushu.i#gmail.com
I would try http://drupal.org/project/subscriptions module + http://drupal.org/project/messaging module. You can set preferences for automatic subscribing to content type. Maybe Rules module can subscribe users automatically after creating or updating content_profile. Or maybe Rules can flag users after creating or updating content_profile and Subscription module could autosubscribe flagged users.