magento2 – Magento 2 – How to get product attribute in order api

I added two new product attributes to a product called

netsuite_internal_id & ava_tax_code

if I do a GET to /rest/V1/products/{sku}, I can see them in custom_attributes.attribute_code.

When a customer places and order I need those product attribute to show up in the “items” node. When doing a GET to /rest/V1/orders/{orderId}

ORDER REST API
enter image description here

PRODUCT REST API
enter image description here

8 – How to get a product variant field (not attribute) value?

I have created a product variant with 1 attribute (say “Subscription Plan” or attribute_sub_plan) and 1 field (say “Number of Issues” or field_num_issues). The attribute was for human readability while the field was an integer for internal use.

The attribute was added to the variation type when created, while the field was added to the variation type on the “Add field” button after creation. I can see both fields in the Product Variant interface.

I can easily get the attribute value like this:

$plan_name = $variation->getAttributeValue('attribute_sub_plan')->getName();

However, I cannot get the field value like I usually can with other entities:

$num_issues = $variation->get('field_num_issues')->value;

As a matter of fact, I cannot even get the field “field_num_issues”. It gives me this error:

InvalidArgumentException with message 'Field field_num_issues is unknown.'

Do you have any idea how I can get the value?

magento2.3 – Size attribute doesn’t have any options

I encounter this issue before while using custom extension.

It is caused by the layout on product page there are multiple layout calls some by ajax some by other means before reload it will not show options because it is not refreshing that specific layout from where options are coming but on reload it will refresh all layouts on that page along with that layout thats why it is behaving like this.

hope this helps

javascript – How to import styles.css into my iframe srcdoc attribute

How can I import styles.css into my iframe srcdoc attribute?
The hash is changing on almost every build since I add css regularly.
Seems very inefficient to manually hardcode the hash everytime it changes and then run gatsby build again, any way to dynamically solve this?

I’m using gatsby@3.6.0, tailwindcss@2.1.4

<iframe srcdoc={'<html lang="en"><head> <link rel="stylesheet" href="/styles.HASH.css"> <title></title> </head> <body></body></html>'}></iframe>

custom taxonomy – update attribute of specific products in woocommerce

I need to change the value of all product attributes that have a specific attribute with a specific value.
for example, I have 10 phones with Ram(attribute): 64 GiB (attribute value) and 5 Phone with Ram(attribute): 64 GB (attribute value).
I need to change all products with Ram: 64 GiB to Ram: 64 GB, So there will be no 64GiB anymore, I tried the below code and https://stackoverflow.com/a/65690805/6934036. but they didn’t work

$product_id = 14352; //some product id
$storage = get_the_terms($product_id, 'pa_internal-storage');
$newStorage = '64GB';
update_post_meta($product_id, 'pa_internal-storage', $newStorage);

html – Does adding a “title” attribute to the “label” element instead of the “input” harm accessibility?

I’m creating an HTML interface that has an input text field with a label attached. The label has a short name for the input and I want a more detailed description to appear as a popup for visual users, but also to be accessible for screen readers.

This can be done with the title attribute, but if I attach the title to the input element, it will only show when hovering over the input. If I attach it to the label element, then both the label and the input can be hovered to see the tooltip.

I am wondering if this will impact screen readers somehow, and read the title out in a way that could confuse non-visual users.

Here’s an example of the code:

<label title="Some extra details">
    Your Input:
    <input type="text" />
</label>

I haven’t found any such usage in the W3 docs, but I there was one suggestion from StackOverflow. I’m just concerned it might impact accessibility.

Attribute user to original source after multiple sessions in Google Analytics

We are running a contest on our site. To enter the contest, users click a call to action button on the landing page which takes them to a third-party website to fill out the form (submittable.com) and after they finish the form are re-directed back to a specific thank you page on our site.

The problem is, Google Analytics is attributing all of these users to the third-party form site- which is only a middle step in the funnel- rather than where they originally came from (organic, search, facebook ads). We’d like to be able to measure how many came through the facebook ads and completed a form, despite redirecting to a third-party site as one of the steps.

Is there any way to track users across multiple sessions to attribute where they originally came on successful completion of a goal in GA?

csrf – srcdoc attribute of iframes as a source of XSS attacks

I am trying to implement a case where a user provides us some html code which is then stored in our database. We then retrieve the HTML from our database as a string. (We have no control over the user input)

I try to embed this html using

const htmldoc = (the raw html)
<iframe sandbox="allow-scripts" srcdoc=htmldoc>
</iframe>

I would be using a data:// URI. Or blob:// URI.

I am using the sandbox attribute to prevent Same Origin Policy. Can a user input something which might lead to XSS attacks in the parent browsing context? I am not concerned if the XSS attack targets the content inside the iframe since it is sandboxed.

If my approach is vulnerable to attacks, what can I do to make it secure?

advanced search – Problem with Magento2 attribute

Luma theme, I added a custom dropdown attribute in admin, add 2 options and on the advanced search page we see a dropdown, but when I add more than 3 options, the dropdown on the advanced search page is displayed as a multiselect, why is this happening and how to fix it?

magento2 – How can I do product sorting on configurable’s child product attribute data depending on the layered navigation filter selection

I have a particular requirement where I need to do product sorting on configurable’s child product attribute data depending on the layered navigation filter selection.

The following illustration will help to understand the requirement in a better way.

  • Have a site that offers some courses, it is represented by a configurable product in M2.
  • Each course runs multiple times in a year, so they are child virtual products assigned to the configurable product.
  • Each course occurrence (child product) has a start date.
  • The “soonest” start date is held in an attribute against the parent course (latest date from children) and when we’re not filtering we can sort by this date and results are fine. For example, if we searched today you’d see courses starting next week at the top of the list.
  • When we add in a filter for a month like “September” the results returned will show the courses that have an occurrence happening in September – so this is fine. But the search by soonest is still looking at the earliest course start date.
    For example, course A had an occurrence on June 5th and one in September on September 20th, and course B had June 20th and September 5th.
    So the customer expects course B to show first because it starts sooner in September but the sort is still looking at that overall soonest date – parent not child.

So the problem is – how do we use the occurrence date of the child product when we’ve filtered. When I tried to set the child value into the layer collection item through customer code, it breaks the pagination.

Any help would be appreciated.