sylius: Order (list) the items in a taxonomy - sylius

Is there a way of order taxons in a taxonomy
and order products within a taxonomy ?
Has something been done or is it a personal TODO thing in Sylius ?

Related

Raw sql query to get product count against attribute options Magento2

Hi i need to get all the product attributes and the count of products against each attribute option on my custom page.
Filtering magento confection on the basis of attribute is taking so long . So i need direct sql query to achieve this.
Please provide me some reference or code.
You can use GROUP BY and COUNT(*) to count the number of products against each attribute.
SELECT ATTRIBUTE, COUNT(*)
FROM YOUR_TABLE
GROUP BY ATTRIBUTE;
More:
mysql count group by having

Bigcommerce API - In Orders, what does the id represent?

In orders(https://developer.bigcommerce.com/api/stores/v2/orders), what does the id represent? Is that order_id? id is explained in documentation as "The ID of the order, a read-only value. Do not pass in PUT or POST."
However, if we look at id property under order product(https://developer.bigcommerce.com/api/objects/v2/order_product), there are id, order_id, and product_id.
I am confused what id represent in orders and order product.
Both values represent individual auto assigned unique numbers. When you upload or add new products each product is assigned a product_id and when an order is placed or in the abandon cart saver feature it gets assigned a order_id.
If you go to the Bigcommerce product page and view-source you will see your product_id
example <input type="hidden" name="product_id" value="94" />
Hope that helps

SQL Query - Don't grab this unless this

I'm modifying a query I have that pulls news items from my database. These news items have tags, which, in the database, is stored in a single column as a string separated by commas.
For example:
'content,video,featured video,foo'
What I'm trying to do is grab all the items in the table but not the items that contain 'video' in the tags string, unless the tag string also contains 'featured video'
What is the best way to do this?
Here is my query:
SELECT *
FROM posts
WHERE status = 2
ORDER BY postDate
I'm offering horrible thing, but if you want to stick to your table structure, you may try following:
SELECT * FROM posts
WHERE STATUS=2 AND
INSTR(tags,'featured video')>0
OR
INSTR(tags,'video')=0
At least use FULLTEXT index on that field, so it won't be this painful to use.
Probably not the best way to do it...
Select *
FROM posts
where status = 2
AND postID NOT IN
(SELECT postID FROM posts
WHERE tag LIKE '%Video%'
AND tag NOT like '%Featured Video%')
I am assuming PostId to be the PK from the posts table btw...
I would use a query like this:
SELECT
*
FROM
posts
WHERE
status = 2
AND (CONCAT(',', tags, ',') LIKE '%,featured video,%'
OR CONCAT(',', tags, ',') NOT LIKE '%,video,%')
ORDER BY
postDate

'Autosuggestion' feature implementation for a webapp

I'm developing a web application and have two models (among others) - users and items with many-to-many association. So I have have tables 'users', 'items' and 'items_users' with primary key 'id' and foreign keys user_id and item_id.
What I'm going to have is an 'autosuggestion' feature. If, say, I'm as a user mark a certain item as good, the system is supposed to suggest n items I most probably would also mark as good. The reasonable criteria for autosuggestion is how many users who liked the first item like another one. If all users who like tea also like a teapot - then the teapot is in top position for autosuggestion.
This is basic functionality, I'll also filter some results but the rest doesn't matter. I'm thinking about some kind of an auxiliary table for fast calculation on demand or scheduling a separate process to calculate n suggestions.
Thank you for any related information!
UPD
The question sounded unclear. I have sql db and sinatra with sequel orm. I'm asking about how to calculate most similar items dataset (cheapest, least resourse consuming approach). How would you implement it?
So, generally you want to select all users that liked the same products then get the products they like by counting the numer of likes for each product and output the most liked products.
So how would this look in SQL?
Let's see how would this look in SQL:
Step 1: Get the id's of your favourites
SELECT it.item_id FROM `item_users` it WHERE it.user_id = %current_user%
Step 2: Get the users who like the same items
SELECT u.id FROM `item_users` it, `users` u WHERE it.item_id IN (
SELECT it.item_id FROM `item_users` it WHERE it.user_id = %current_user%
) AND it.user_id != %current_user% AND u.id = it.user_id GROUP BY it.user_id
Step 3: Get their favourites
And the entire SQL query would look like this:
SELECT i.* FROM `items` i, `item_users` it WHERE it.user_id IN (
SELECT u.id FROM `item_users` it, `users` u WHERE it.item_id IN (
SELECT it.item_id FROM `item_users` it WHERE it.user_id = %current_user%
) AND it.user_id != %current_user% AND u.id = it.user_id GROUP BY it.user_id
) AND i.id = it.item_id GROUP BY i.id ORDER BY count(*) DESC
Your task is to add limiting of the results...
UPDATE:
I guess that you would like to get the most populat products first. I've changed the query to add that functionality (added ORDER BY count(*) DESC to the end)
This is a complex query and using ActiveRecord to implement it would be quite slow and even more complicated, so I would recommend you using the query as is.
Use your link table to join users and items.
Apply following filters in your WHERE-Clause:
- users that liked the item ("marked it as good")
- items, that the current user did not already mark as good
Sort descending by the number of likes (you'll need to group by the item id and count the users).

linqpad query to connect two entities in odata

I am using linqpad. I have an ODATA connected. The entities are listed in left pane with relationships. There are two entities called Products and Customers. I have to get all the product id starting with pid and names of all customers startin with b. There is a relationship between both. Product is a child of customer. How do I do? I am trying since two days but unable to figure it out. Anyone could help?
this is the base code. i dont no what to do further.
from p in products
where p.ProductId.StartsWith("Pid")
from c in customers
where c.Name.StartsWith("B")
select new
{
p.Pid,
c.Name
};
Can you please specify how you want the relation between the two entities to affect the result of the query? Do you expect the above to only returns products (with ID starting with a given value) and then only the customers for those products which name starts with a certain value?
Such a query is not expressible in OData unfortunately. You could request all products which ID starts with a specific value, and all the related customers. And then filter the customers on the client.
For example this will get you all the products which ID starts with a certain value and all their customers:
from p in products
where p.ProductId.StartsWith("Pid")
select new Product
{
ProductId = p.ProductId,
Customers = p.Customers
};