Filtering out, out-of-stock products from BonusDiscountLineItem demandware - demandware

By default BonusDiscountLineItem.bonusProducts will return out of stock products as well, is there any way to filter out the out of stock products from bonusProducts list?

We can filter out the list returned by BonusDiscountLineItem.bonusProducts.
We can us IsOrderable() and IsInStock() methods for filtering out the OUT OF STOCK products.

Related

Export BigCommerce Variant IDs

Is there a way for a user to export all variants with their IDs in BigCommerce? After inspecting the built-in Bulk Edit template in Products -> Export, I don't believe it gives the variant IDs. For rows with an Item Type of Product, the Product ID column shows the product ID. But for rows with an Item Type of SKU, it appears to be showing a SKU ID rather than the variant ID. I need the variant IDs to use the bulk update API endpoint to update variant inventory levels.

Magento 2 rest order API show duplicate sku in order item if product is configurable

I am getting Magento 2 order details by rest order API but the result is showing the same SKU in configured product order item that is creating an issue in SAP integration.
Anyone let me know how can we overwrite Magento 2 rest API code?
You should not need to “overwrite magento 2 rest API code” because what you described is perfectly normal and expected.
In Magento orders, each configurable product creates two sales order line items due to the way that configurable product data is structured in the catalog. One line corresponds to the “parent” catalog product, and one corresponds to the specific variant “child” (simple) product. Both records contain the same SKU value but their product IDs are different.
In order to get all information about the ordered item both of those records could be important, however if you can get by with just the data from the simple product then you could filter your REST request like below:
GET <host>/rest/V1/orders/items?
searchCriteria[filter_groups][0][filters][0][field]=order_id&
searchCriteria[filter_groups][0][filters][0][value]=1&
searchCriteria[filter_groups][1][filters][0][field]=product_type&
searchCriteria[filter_groups][1][filters][0][value]=simple

How to avoid customer's order history being changed in MongoDB?

I have two collections
Customers
Products
I have a field called "orders" in each of my customer document and what this "orders" field does is that it stores a reference to the product Id which was ordered by a customer, now my question is since I'm referencing product Id and if I update the "title" of that product then it will also update in the customer's order history since I can't embed each order information since a customer may order thousands of products and it can hit 16mb mark in no time so what's the fix for this. Thanks.
Create an Orders Collection
Store ID of the user who made the order
Store ID of the product bought
I understand you are looking up the value of the product from the customer entity. You will always get the latest price if you are not storing the order/price historical transactions. Because your data model is designed this way to retrieve the latest price information.
My suggestion.
Orders place with product and price always need to be stored in history entity or like order lines and not allow any process to change it so that when you look up products that customers brought you can always get the historical price and price change of the product should not affect the previous order. Two options.
Store the order history in the current collection customers (or top say 50 order lines if you don't need all of history(write additional logic to handle this)
if "option1" is not feasible due to large no. of orders think of creating an order lines transaction table and refer order line for the product brought via DBref or lookup command.
Note: it would have helped if you have given no. of transactions in each collection currently and its expected rate of growth of documents in the collection QoQ.
You have orders and products. Orders are referencing products. Your problem is that the products get updated and now your orders reference the new product. The easiest way to combat this issue is to store full data in each order. Store all the key product-related information.
The advantage is that this kind of solution is extremely easy to visualize and implement. The disadvantage is that you have a lot of repetitive data since most of your products probably don't get updated.
If you store a product update history based on timestamps, then you could solve your problem. Products are identified now by 3 fields. The product ID, active start date and active end date. Or you could configure products in this way: product ID = product ID + "Version X" and store this version against each order.
If you use dates, then you will query for the product and find the product version that was active during the time period that the order occurred. If you use versions against the product, then you will simply query the database for the particular version of the product itself. I haven't used mongoDb so I'm not sure how you would achieve this in mongoDb exactly. Naively however, you can modify the product ID to include the version as well using # as a delimiter possibly.
The advantage of this solution is that you don't store too much of extra data. Considering that products won't be updated too often, I feel like this is the ideal solution to your problem

Comparing simple products of grouped/configurable products in Magento2

Is it possible to compare simple products that belong to a grouped/configurable product?
We are using configurables/grouped products in Magento2
The associated simple products are set „not visible individually“ in the Backend (Visibility-Attribute).
We need to be able to use the compare funktion for the associated simple products without changing the visibility for those.
Thanks for your help!

Filtering and ordering

I am building a news feed app and I need to filter news by category while ordering them by data.
The only way I was able to achieve this was by duplicating the news, one for a category name 'All' and another for the category it belongs.
Is there a way filter by category and order by the timestamp?
Edit:
this is an example of my db structure.
news
-All
-category: "category1"
-sortDate: -1477585147
-Category1
-Category2
-Category3
Doing this way i am able to filter as i want, but i have to duplicate all the news.