Php 如何在prestashop中获取所有属性
我需要获取我的Prestahop存储中存在的所有属性,不管是哪个或分配了什么产品,我只想生成这些属性的数组,然后在ProductController.php类中使用它们。我检查了文件classes/Product.php,发现了一个名为getDefaultAttribute$id_Product,$minimumQuantity=0的方法,但我认为这只适用于分配给特定产品的属性,而不是返回我需要的所有属性。有什么帮助吗?我是Prestashop的新手,需要学习很多东西检查文件类/Attribute.php。您可以使用静态函数Attribute::getAttributes$id\u lang,$not\u null=false。它返回给定语言的所有属性。检查文件类/Attribute.php。您可以使用静态函数Attribute::getAttributes$id\u lang,$not\u null=false。它返回给定语言的所有属性。您可以使用以下SQL查询获取所有属性:Php 如何在prestashop中获取所有属性,php,e-commerce,smarty,prestashop,Php,E Commerce,Smarty,Prestashop,我需要获取我的Prestahop存储中存在的所有属性,不管是哪个或分配了什么产品,我只想生成这些属性的数组,然后在ProductController.php类中使用它们。我检查了文件classes/Product.php,发现了一个名为getDefaultAttribute$id_Product,$minimumQuantity=0的方法,但我认为这只适用于分配给特定产品的属性,而不是返回我需要的所有属性。有什么帮助吗?我是Prestashop的新手,需要学习很多东西检查文件类/Attribut
$atbt = "SELECT a.id_attribute_group , a.name
FROM " . _DB_PREFIX_ . "attribute_group_lang a
where id_lang='".$id_lang."'";
$res = Db::getInstance()->ExecuteS($atbt);
$product_result = array();
$i=0;
foreach ($res as $key => $row) {
$sql = 'SELECT pal.name AS label,pal.id_attribute AS value,0 AS status'
. ' FROM ' . _DB_PREFIX_ . 'attribute AS pa
RIGHT JOIN ' . _DB_PREFIX_ . 'attribute_group_lang AS pagl ON (pagl.id_attribute_group =pa.id_attribute_group)
LEFT JOIN ' . _DB_PREFIX_ . 'attribute_lang AS pal ON (pal.id_attribute =pa.id_attribute)
JOIN ' . _DB_PREFIX_ . 'product_attribute_combination AS pacl ON (pacl.id_attribute =pal.id_attribute)
JOIN ' . _DB_PREFIX_ . 'product_attribute AS pat ON (pat.id_product_attribute =pacl.id_product_attribute)
JOIN ' . _DB_PREFIX_ . 'product AS prot ON (prot.id_product =pat.id_product)
WHERE pagl.id_lang="'.$id_lang.'" AND pal.id_lang="'.$id_lang.'" AND pagl.id_attribute_group=' . $row['id_attribute_group'].' AND prot.id_category_default = "'.$id_category.'" GROUP BY pacl.id_attribute';
$result = Db::getInstance()->ExecuteS($sql);
}
您可以使用以下SQL查询获取所有属性:
$atbt = "SELECT a.id_attribute_group , a.name
FROM " . _DB_PREFIX_ . "attribute_group_lang a
where id_lang='".$id_lang."'";
$res = Db::getInstance()->ExecuteS($atbt);
$product_result = array();
$i=0;
foreach ($res as $key => $row) {
$sql = 'SELECT pal.name AS label,pal.id_attribute AS value,0 AS status'
. ' FROM ' . _DB_PREFIX_ . 'attribute AS pa
RIGHT JOIN ' . _DB_PREFIX_ . 'attribute_group_lang AS pagl ON (pagl.id_attribute_group =pa.id_attribute_group)
LEFT JOIN ' . _DB_PREFIX_ . 'attribute_lang AS pal ON (pal.id_attribute =pa.id_attribute)
JOIN ' . _DB_PREFIX_ . 'product_attribute_combination AS pacl ON (pacl.id_attribute =pal.id_attribute)
JOIN ' . _DB_PREFIX_ . 'product_attribute AS pat ON (pat.id_product_attribute =pacl.id_product_attribute)
JOIN ' . _DB_PREFIX_ . 'product AS prot ON (prot.id_product =pat.id_product)
WHERE pagl.id_lang="'.$id_lang.'" AND pal.id_lang="'.$id_lang.'" AND pagl.id_attribute_group=' . $row['id_attribute_group'].' AND prot.id_category_default = "'.$id_category.'" GROUP BY pacl.id_attribute';
$result = Db::getInstance()->ExecuteS($sql);
}
感谢@alexander simonchik在看到我使用的代码$query\u attributes=SELECT ps\u al.name FROM之后_DB_前缀。属性为左连接_DB_前缀。ps_al.id_lang=ps_agl.id_lang左联接上的属性\u group_lang ps_agl_DB_前缀。ps_a.id_attribute_group=ps_agl.id_lang上的属性ps_a,其中ps_al.id_lang=。int配置::获取“PS_LANG_DEFAULT”;$attributes=Db::getInstance->执行$query\u属性;$existence\u attributes=数组;foreach$attributes作为$attr{$existence_attributes[]=$attr['name'];}感谢@alexander simonchik,在看到我使用的代码后,$query_attributes=SELECT ps_al.name FROM_DB_前缀。属性为左连接_DB_前缀。ps_al.id_lang=ps_agl.id_lang左联接上的属性\u group_lang ps_agl_DB_前缀。ps_a.id_attribute_group=ps_agl.id_lang上的属性ps_a,其中ps_al.id_lang=。int配置::获取“PS_LANG_DEFAULT”;$attributes=Db::getInstance->执行$query\u属性;$existence\u attributes=数组;foreach$attributes为$attr{$existence_attributes[]=$attr['name'];},而这个代码片段可能会解决这个问题,包括一个提高文章质量的解释。记住,你是在将来回答读者的问题,而不仅仅是现在提问的人!请在回答中添加解释,并说明适用的限制和假设。而此代码片段可能会解决此问题,包括提高文章质量的解释。记住,你是在将来回答读者的问题,而不仅仅是现在提问的人!请在回答中添加解释,并说明适用的限制和假设。