magento后台设置好产品分类及添加产品后前台没有显示出来,请教是怎么回事

magento后台设置好产品分类及添加产品后前台没有显示出来,请教是怎么回事,第1张

一下几个可能:

1 添加新品要重新index一下,magento是静态的html页面,不reindex不出来的。在System→Index Management里面,全选后点Reindex。

2 产品有很多属性影响是否前台显示:

qty:数量为0前台不显示。

is_in_stock:no的话前台不显示。

status:disable的话前台不显示

visibility:none的话前台不显示。

3 有的时候,如果你 *** 作不当,cache也会影响,到system→Cache Management里面,清空所有cache。建议测试阶段就直接关闭缓存功能就好了。

集合是一个包含其他型号的机种型号,它基本上是用在Magento处理的产品清单(即从类别或捆绑选项),但不是唯一的。TO DO:解释如何Magento的实现集合 – 使用此解释如何Magento的实现代码模型中的一个集合,使人们可以学会写自己的藏品这是一个简单的例子,加载一些产品集合从一个类别,并命令他们在自己的产品名称使用Magento的API的。$collection = Mage::getModel('catalog/category')->load($categoryId) ->getProductCollection() ->addAttributeToSort('name', 'ASC');使用多个字段排序,您可以调用链接到该集合的方法 addAttributeToSort(preferred)$collection = Mage::getModel('module/model_name')->getCollection() ->addAttributeToSort('order', 'ASC') ->addAttributeToSort('last_name', 'ASC') ->addAttributeToSort('first_name', 'ASC')TODO:使用Magento的API使用的情况下,不是Zend_Db_Select的。您也可以通过IF/THEN语句,但一定要使用正确引用表的字段。$collection = Mage::getModel('module/model_name')->getCollection(); $collection->getSelect()->order( array('IF(`order`>0, `order`, 9999) ASC', 'last_name ASC', 'first_name ASC') );在此示例中,将按顺序字段,排序表然后按上次的名称,然后按名字、 凡订单是否大于零,是秩序正在小于或等于零,所有升序。联接表若要添加 SQL 联接到选择$collection = Mage::getModel('module/model_name')->getCollection(); $collection->getSelect()->join( array('table_alias'=>$this->getTable('module/table_name')), 'main_tableforeign_id = table_aliasprimary_key', array('table_alias'), 'schema_name_if_different');在此示例中的联接方法采用 alias�6�0table_name 密钥对,然后使用 main_table 引用原始的选择中,标准的 join 子句的数组然后在联接中要检索的字段的数组 (默认为 ),可以作为最后一个参数指定不同的架构。复审→ 默认为内部联接,其他人可以使用:→joinInner() →joinLeft() →joinRight() →joinFull() →joinCross() →joinNatural()请参阅 lib/Zend/Db/Selectphp 的源码。集合 *** 作方法Varien_Data_CollectionVarien/Data/CollectionphpaddFilter($field, $value, $type = ‘and’)addItem(Varien_Object $item)clear()count()distinct($flag)each($obj_method, $args=array())getAllIds()getCacheKey()getCacheLifetime()getCacheTags()getColumnValues($colName)getCurPage($displacement = 0)getFirstItem()getFlag($flag)getItemByColumnValue($column, $value)getItemById($idValue)getItems()getItemsByColumnValue($column, $value)getIterator()getLastItem()getLastPageNumber()getNewEmptyItem()getPageSize()getSize()hasFlag($flag)isLoaded()loadData($printQuery = false, $logQuery = false)load($printQuery = false, $logQuery = false)removeItemByKey($key)setCacheKey($key)setCacheTags($tags)setCurPage($page)setDataToAll($key, $value=null)setFlag($flag, $value = null)setOrder($field, $direction = self::SORT_ORDER_DESC)setPageSize($size)toArray($arrRequiredFields = array())toOptionArray()toOptionHash()toXml()walk($callback, array $args=array())Varien_Data_Collection_DbVarien/Data/Collection/Dbphp 继承Varien_Data_Collection,除了上面的方法(重新)定义如下:addBindParam($name, $value)addFieldToFilter($field, $condition=null)addOrder($field, $direction = self::SORT_ORDER_DESC)distinct($flag)getConnection()getData()getIdFieldName()getSelect()getSelectCountSql()getSize()initCache($object, $idPrefix, $tags)loadData($printQuery = false, $logQuery = false)load($printQuery = false, $logQuery = false)printLogQuery($printQuery = false, $logQuery = false, $sql = null)resetData()setConnection($conn)setOrder($field, $direction = self::SORT_ORDER_DESC)unshiftOrder($field, $direction = self::SORT_ORDER_DESC)筛选器的条件代码Attribute CodeSQL�0�2EquivalentDescriptioneq=neq!=likeLIKEnlikeNOT LIKEinIN ()ninNOT IN ()isISnotnullIS NOT NULLnullIS NULLmoreq>=gt>lt<gteq>=lteq<=finsetFIND_IN_SET()from>=for use with datesto<=for use with datesdateoptional flag for use with�0�2from/to�0�2to specify that comparison value should first be converted to a�0�2datedatetimeoptional flag for use with�0�2from/to�0�2to specify that comparison value should first be converted to a�0�2datetime如果传递的数组,但没有属性代码指定,它将被解释为一组 OR 条件将在相同的方式进行处理。如果不指定了任何属性代码,则其默认值为不等。

例如:$collection->addAttributeToFilter('field_name', array( 'in' => array(1, 2, 3), )); $collection->addAttributeToFilter('date_field', array( 'from' => '2000-09-10', )); $collection->addAttributeToFilter('date_field', array( 'from' => '10 September 2000', 'to' => '11 September 2000', 'date' => true, // specifies conversion of comparison values )); $collection->addAttributeToFilter('field_name', array( 'notnull' => true, )); $collection->addAttributeToFilter('field_name', 1); // tests for equality// Add OR condition:$collection->addAttributeToFilter(array( array( 'attribute' => 'field_name', 'in' => array(1, 2, 3), ), array( 'attribute' => 'date_field', 'from' => '2000-09-10', ), ));Mage_Eav_Model_Entity_CollectionMage/Eav/Model/Entity/Collection/Abstractphp 继承上述方法Varien_Data_Collection_Db,除了(重新)定义了以下:addAttributeToFilter($attribute, $condition=null, $joinType=’inner’)adds�0�2WHERE�0�2clause on $attribute specified by $conditionaddAttributeToSelect($attribute, $joinType=false)gets the value for $attribute in the�0�2SELECT�0�2clause;

specify�0�2�0�2to get all attributes (ie to execute�0�2SELECT )addAttributeToSort($attribute, $dir=’asc’)adds�0�2ORDER BY�0�2clause on $attributeaddEntityTypeToSelect($entityType, $prefix)doesn’t seem to do anything – don’t useaddExpressionAttributeToSelect($alias, $expression, string|array $attribute)adds�0�2SQL�0�2expression $expression, using $alias, to�0�2SELECT�0�2clause (typically containing aggregate functions such as�0�2SUM(),�0�2COUNT());

when $attribute specifies a single attribute as a string, $expression can reference the attribute as simply�0�2{{attribute}}, but when passing an array of attributes, each attribute must be referenced in $expression by the name of the specific attribute;

NB use with�0�2groupByAttribute()�0�2when including aggregate functions qvaddFieldToFilter($attribute, $condition=null)alias for�0�2addAttributeToFilter()addItem(Varien_Object $object)adds an object to the collectionaddStaticField($field)specifies $field as being static, ie as existing on the entity table itself, rather than in the EAV tabledelete()deletes all entities in the collectionexportToArray()returns collection data as a 2D arraygetAllIds($limit=null, $offset=null)returns array of all entity IDs selected by current�0�2WHERE�0�2clause (optionally specifying $limit and $offset)getAllIdsSql()not recommended – don’t usegetAttribute($attributeCode)for specified $attributeCode, returnsMage_Eav_Model_Entity_Attribute_Abstract�0�2object of the entity object used by the collection (ie calls�0�2getAttribute($attributeCode)�0�2on the entity object and returns the result)getEntity()returns�0�2Mage_Eav_Model_Entity_Abstract�0�2object used by collection for attributesgetLoadedIds()returns array of IDs of currently loaded entitiesgetResource()returns�0�2Mage_Core_Model_Resource_Abstract�0�2instance;

actually an alias for�0�2getEntity()�0�2qv (an entity is a special type of resource, that is,�0�2Mage_Eav_Model_Entity_Abstract�0�2extendsMage_Core_Model_Resource_Abstract)getRowIdFieldName()returns field name of ID attribute for entities in the collectiongetTable($table)alias for�0�2Mage::getSingleton(‘core/resource’)->getTableName($table)groupByAttribute($attribute)adds $attribute to�0�2GROUP BY�0�2clauseimportFromArray($arr)imports 2D array into collection as objectsjoinAttribute($alias, Mage_Eav_Model_Entity_Attribute_Abstract|string $attribute, string $bind, string $filter=null, string $joinType=’inner’, $storeId=null)joins another entity and adds attribute from joined entity, using $alias, to�0�2SELECT�0�2clause;

$attribute can specify attribute object, or string in format[entity]/[attribute];

$bind specifies attribute of the main entity on which to make join;

$filter specifies primary key of the joined entity on which to make join (normally defaults to�0�2entity_id);

$joinType should be�0�2inner�0�2or�0�2leftjoinField($alias, $table, $field, $bind, $cond=null, $joinType=’inner’)joins regular table field using an attribute as foreign keyjoinTable($table, $bind, $fields=null, $cond=null, $joinType=’inner’)joins table $tableload($printQuery = false, $logQuery = false)runs query and load data into collection;

specify $printQuery as�0�2true�0�2to print�0�2SQL�0�2for debuggingremoveAttributeToSelect($attribute=null)removes $attribute from�0�2SELECT�0�2clause;

specify�0�2null�0�2to remove all attributessave()saves all entities in the collectionsetEntity(string|object $entity)sets entity object (ie�0�2Mage_Eav_Model_Entity_Abstract) used by collection for attributessetObject(Varien_Object $object=null)sets template object for the collectionsetOrder(string| $attribute, $dir=’desc’)alias for�0�2addAttributeToSort()�0�2qv, identical except that it can accept array of attributes, and default $dir is�0�2desc;

�0�3

原因:关联了多表后,表与表之间有相同字段出现。在多表查询时,如何正确的写SQL,我想你应该知道是什么原因了,就是字段归属的问题。我也是折腾了好久才知道是什么原因,起初一直认为Magento会处理这个问题,我真的错了。

原来Column可以设置filter_index,之前自己还尝试’index’=>’main_tableincreament_id’等等,原来这样就可了,于是上面我改的代码变成了这样:

$this->addColumn('increment_id', array(

'header' => G::helper('sales')->__('Shipment #'),

'index' => 'increment_id',

'filter_index' =>'main_tableincrement_id',

'type' => 'text',

));

完整内容请查看,嗨 · 酷哥网

以上就是关于magento后台设置好产品分类及添加产品后前台没有显示出来,请教是怎么回事全部的内容,包括:magento后台设置好产品分类及添加产品后前台没有显示出来,请教是怎么回事、在Magento 中如何使用集合查询条件、如何解决Magento Grid报错clause is ambiguous问题等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/9768902.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-01
下一篇2023-05-01

发表评论

登录后才能评论

评论列表(0条)

    保存