我试图从Magento2RESTAPI和产品类别中获得所有产品的列表(我想在另一个应用程序中构建一个树视图)。
我可以查询所有的SKU,然后逐个运行SKU,但是这需要很长时间,我宁愿调用一个API,一次得到所有的产品/类别关系。
如果一次查询所有SKU,就不会得到category_ids属性,该属性显示项目属于哪些类别。
GET: http://someurl/rest/V1/products?searchCriteria=
// e.g. this is missing when querying for multiple SKUs
{
"attribute_code"
我有一个查询,它在一个子类别下显示问题,在一个类别下显示更多的问题,因为在一个类别下有一个子类别。这是我的密码
SELECT
a.*
FROM question a
LEFT JOIN category b on a.question_subcat = b.category_id
WHERE b.parentcategoryid = $question
如何包括如何显示具有空值的question_subcat,而不只是显示具有值的值?因为我的问题不一定都在一个子类别下,所以它可以只是在一个类别下,而不是在任何子类别中,从而使其为空。我该怎么显示?
我刚学过拉拉5.2。
有谁能帮助我用一个例子来定义类别-子类别-产品之间的模型关系,以及如何通过相关id获取子类别下的产品?
// Category model
public function subcategories(){ return $this->hasMany('App\Subcategory', 'category_id'); }
public function products() {return $this->hasMany('App\Product', 'subcategory_id'
我正在建立一个产品数据库。每种产品都属于一个类别。只能存在子子类别下的产品。每个产品都有像name,ean_number,price,width,height,depth,weight等属性,但也有一些基于类别的自定义属性!像energy_class,number_of_programs,sound_volume等等!我说的是这样的东西:
Category
|
|--Category <- This Category have extra information about extra attributes for Products
| |
| |--Cate
在学习EF时,碰巧看到了链接,需要对下面的代码做两个小的说明
// Currently, the Entity Framework doesn’t mark the entities
// that are removed from a navigation property (in our example the Products)
// as deleted in the context.
// The following code uses LINQ to Objects against the Local collection
// to find all product
我通过目录菜单添加了新的类别。但它没有在前端显示类别。
1.类别在默认类别下。
2.是否为Active -Yes
这些是我对新类别所做的设置。保存后,当我转到前端时,它不显示类别。如何让添加到此类别下的产品出现在前端。
生成的类别id为72表示该问题。下面提供的代码是我在.phtml文件上用来显示类别id(72)的产品的代码。除了类别id 72(这是新创建的)之外,其余所有其他类别产品我都可以通过传递类别id来检索。
<?php
$categoryId = 72;
//here $categoryId is the id of the category
$cate