本文整理汇总了PHP中Mage_Eav_Model_Entity_Collection_Abstract类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Eav_Model_Entity_Collection_Abstract类的具体用法?PHP Mage_Eav_Model_Entity_Collection_Abstract怎么用?PHP Mage_Eav_Model_Entity_Collection_Abstract使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Eav_Model_Entity_Collection_Abstract类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getPostCollection
/**
* Retrieve loaded category collection
*
* @return Mage_Eav_Model_Entity_Collection_Abstract
*/
protected function _getPostCollection()
{
if (is_null($this->_postCollection)) {
$this->_postCollection = Mage::getModel('vc_miniblog/post')->getCollection();
$this->_postCollection->setPageSize(Mage::getStoreConfig('vc_miniblog/menu_link/recent_post'));
}
return $this->_postCollection;
}
示例2: joinTableToEavCollection
/**
* Join url rewrite table to eav collection
*
* @param Mage_Eav_Model_Entity_Collection_Abstract $collection
* @param int $storeId
* @return Mage_Catalog_Helper_Category_Url_Rewrite
*/
public function joinTableToEavCollection(Mage_Eav_Model_Entity_Collection_Abstract $collection, $storeId)
{
if ($this->_helper()->OptimizeCategoriesLeftJoin($storeId)) {
$collection->joinTable('urlindexer/url_rewrite', 'category_id=entity_id', array('request_path'), "{{table}}.is_system=1 AND " . "{{table}}.store_id='{$storeId}' AND " . "{{table}}.id_path LIKE 'category/%'", 'left');
return $this;
}
return parent::joinTableToEavCollection($collection, $storeId);
}
示例3: addOptionValueToCollection
/**
* Add Join with option value for collection select
*
* @param Mage_Eav_Model_Entity_Collection_Abstract $collection
* @param Mage_Eav_Model_Entity_Attribute $attribute
* @param Zend_Db_Expr $valueExpr
*
* @return Mage_Eav_Model_Mysql4_Entity_Attribute_Option
*/
public function addOptionValueToCollection($collection, $attribute, $valueExpr)
{
$attributeCode = $attribute->getAttributeCode();
$optionTable1 = $attributeCode . '_option_value_t1';
$optionTable2 = $attributeCode . '_option_value_t2';
$collection->getSelect()->joinLeft(array($optionTable1 => $this->getTable('eav/attribute_option_value')), "`{$optionTable1}`.`option_id`={$valueExpr}" . " AND `{$optionTable1}`.`store_id`='0'", array())->joinLeft(array($optionTable2 => $this->getTable('eav/attribute_option_value')), "`{$optionTable2}`.`option_id`={$valueExpr}" . " AND `{$optionTable1}`.`store_id`='{$collection->getStoreId()}'", array($attributeCode => "IFNULL(`{$optionTable2}`.`value`, `{$optionTable1}`.`value`)"));
return $this;
}
示例4: _getProductCollection
/**
* Retrieve loaded category collection
*
* @return Mage_Eav_Model_Entity_Collection_Abstract
*/
protected function _getProductCollection()
{
if (is_null($this->_productCollection)) {
$this->_productCollection = Mage::getModel('vc_shopbybrands/product')->getCollection();
$this->_productCollection->setPageSize(Mage::getStoreConfig('vc_shopbybrands/menu_link/recent_product'));
}
return $this->_productCollection;
}
示例5: _prepareEntityCollection
/**
* Apply filter to collection and add not skipped attributes to select.
*
* @param Mage_Eav_Model_Entity_Collection_Abstract $collection
* @return Mage_Eav_Model_Entity_Collection_Abstract
*/
protected function _prepareEntityCollection(Mage_Eav_Model_Entity_Collection_Abstract $collection)
{
if (!isset($this->_parameters[Mage_ImportExport_Model_Export::FILTER_ELEMENT_GROUP]) || !is_array($this->_parameters[Mage_ImportExport_Model_Export::FILTER_ELEMENT_GROUP])) {
$exportFilter = array();
} else {
$exportFilter = $this->_parameters[Mage_ImportExport_Model_Export::FILTER_ELEMENT_GROUP];
}
$exportAttrCodes = $this->_getExportAttrCodes();
foreach ($this->filterAttributeCollection($this->getAttributeCollection()) as $attribute) {
$attrCode = $attribute->getAttributeCode();
// filter applying
if (isset($exportFilter[$attrCode])) {
$attrFilterType = Mage_ImportExport_Model_Export::getAttributeFilterType($attribute);
if ($attrCode == 'sku') {
$collection->addAttributeToFilter($attrCode, array('in' => $exportFilter[$attrCode]));
} elseif (Mage_ImportExport_Model_Export::FILTER_TYPE_SELECT == $attrFilterType) {
if (is_scalar($exportFilter[$attrCode]) && trim($exportFilter[$attrCode])) {
$collection->addAttributeToFilter($attrCode, array('eq' => $exportFilter[$attrCode]));
}
} elseif (Mage_ImportExport_Model_Export::FILTER_TYPE_INPUT == $attrFilterType) {
if (is_scalar($exportFilter[$attrCode]) && trim($exportFilter[$attrCode])) {
$collection->addAttributeToFilter($attrCode, array('like' => "%{$exportFilter[$attrCode]}%"));
}
} elseif (Mage_ImportExport_Model_Export::FILTER_TYPE_DATE == $attrFilterType) {
if (is_array($exportFilter[$attrCode]) && count($exportFilter[$attrCode]) == 2) {
$from = array_shift($exportFilter[$attrCode]);
$to = array_shift($exportFilter[$attrCode]);
if (is_scalar($from) && !empty($from)) {
$date = Mage::app()->getLocale()->date($from, null, null, false)->toString('MM/dd/YYYY');
$collection->addAttributeToFilter($attrCode, array('from' => $date, 'date' => true));
}
if (is_scalar($to) && !empty($to)) {
$date = Mage::app()->getLocale()->date($to, null, null, false)->toString('MM/dd/YYYY');
$collection->addAttributeToFilter($attrCode, array('to' => $date, 'date' => true));
}
}
} elseif (Mage_ImportExport_Model_Export::FILTER_TYPE_NUMBER == $attrFilterType) {
if (is_array($exportFilter[$attrCode]) && count($exportFilter[$attrCode]) == 2) {
$from = array_shift($exportFilter[$attrCode]);
$to = array_shift($exportFilter[$attrCode]);
if (is_numeric($from)) {
$collection->addAttributeToFilter($attrCode, array('from' => $from));
}
if (is_numeric($to)) {
$collection->addAttributeToFilter($attrCode, array('to' => $to));
}
}
}
}
if (in_array($attrCode, $exportAttrCodes)) {
$collection->addAttributeToSelect($attrCode);
}
}
return $collection;
}
示例6: addOptionValueToCollection
/**
* Add Join with option value for collection select
*
* @param Mage_Eav_Model_Entity_Collection_Abstract $collection
* @param Mage_Eav_Model_Entity_Attribute $attribute
* @param Zend_Db_Expr $valueExpr
* @return Mage_Eav_Model_Resource_Entity_Attribute_Option
*/
public function addOptionValueToCollection($collection, $attribute, $valueExpr)
{
$adapter = $this->_getReadAdapter();
$attributeCode = $attribute->getAttributeCode();
$optionTable1 = $attributeCode . '_option_value_t1';
$optionTable2 = $attributeCode . '_option_value_t2';
$tableJoinCond1 = "{$optionTable1}.option_id={$valueExpr} AND {$optionTable1}.store_id=0";
$tableJoinCond2 = $adapter->quoteInto("{$optionTable2}.option_id={$valueExpr} AND {$optionTable2}.store_id=?", $collection->getStoreId());
$valueExpr = $adapter->getCheckSql("{$optionTable2}.value_id IS NULL", "{$optionTable1}.value", "{$optionTable2}.value");
$collection->getSelect()->joinLeft(array($optionTable1 => $this->getTable('eav/attribute_option_value')), $tableJoinCond1, array())->joinLeft(array($optionTable2 => $this->getTable('eav/attribute_option_value')), $tableJoinCond2, array($attributeCode => $valueExpr));
return $this;
}
示例7: _getGiveawayCollection
/**
* Retrieve loaded Giveaway Product Collection
*
* @return Mage_Eav_Model_Entity_Collection_Abstract
*/
protected function _getGiveawayCollection()
{
if (is_null($this->_productCollection)) {
$oProduct = Mage::getModel('catalog/product');
/* @var $oCollection Mage_Catalog_Model_Resource_Product_Collection */
$this->_productCollection = $oProduct->getResourceCollection();
$oSitewardsGiveawayHelper = Mage::helper('sitewards_giveaway');
$sGiveawayAttributeCode = $oSitewardsGiveawayHelper->getGiveawayIdentifierName();
$this->_productCollection->addAttributeToFilter($sGiveawayAttributeCode, true);
$this->_productCollection->addAttributeToSelect('*');
}
return $this->_productCollection;
}
示例8: _removeHiddenCollectionItems
/**
* Remove hidden items from a product or category collection
*
* @param Mage_Eav_Model_Entity_Collection_Abstract|Mage_Core_Model_Mysql4_Collection_Abstract $collection
*/
public function _removeHiddenCollectionItems($collection)
{
// Loop through each category or product
foreach ($collection as $key => $item) {
$catData = Mage::getModel("catalog/category")->load($item->getEntityId());
// If it is a category
if ($item->getEntityTypeId() == 3 && $item->getLevel() != 2) {
if (strtolower($catData->getUrlKey()) != 'get-the-look' && strtolower($catData->getUrlKey()) != 'new-arrivals') {
if ($this->getProductCountCustom($catData) <= 0) {
$collection->removeItemByKey($key);
}
}
}
}
}
示例9: getLoadedProductCollectionpro
/**
* Retrieve loaded category collection
*
* @return Mage_Eav_Model_Entity_Collection_Abstract
*/
public function getLoadedProductCollectionpro($id)
{
// benchmarking
$memory = memory_get_usage();
$time = microtime();
if (is_null($this->_productCollection)) {
$layer = $this->getLayer();
if ($this->getShowRootCategory()) {
$this->setCategoryId(Mage::app()->getStore()->getRootCategoryId());
}
// if this is a product view page
if (Mage::registry('product')) {
// get collection of categories this product is associated with
$categories = Mage::registry('product')->getCategoryCollection()->setPage(1, 1)->load();
// if the product is associated with any category
if ($categories->count()) {
// show products from this category
$this->setCategoryId(current($categories->getIterator()));
}
}
$origCategory = null;
if ($this->getCategoryId()) {
$category = Mage::getModel('catalog/category')->load($this->getCategoryId());
if ($category->getId()) {
$origCategory = $layer->getCurrentCategory();
$layer->setCurrentCategory($category);
$this->addModelTags($category);
}
}
/* @var $layer Mage_Catalog_Model_Layer */
/* @var $layer Mage_Catalog_Model_Layer */
//$this->_productCollection = $layer->getProductCollection();
/** @var $collection Mage_Catalog_Model_Resource_Product_Collection */
$category = Mage::getModel('catalog/category')->load($this->_theCat);
$this->_productCollection = Mage::getResourceModel('catalog/product_collection');
// join sales order items column and count sold products
$expression = new Zend_Db_Expr("SUM(oi.qty_ordered)");
$condition = new Zend_Db_Expr("e.entity_id = oi.product_id AND oi.parent_item_id IS NULL");
$this->_productCollection->addAttributeToSelect('*')->getSelect()->join(array('oi' => $this->_productCollection->getTable('sales/order_item')), $condition, array('sales_count' => $expression))->group('e.entity_id');
//->order('sales_count' . ' ' . 'desc');
$this->_productCollection->addFieldToFilter('status', '1');
//join brand
if ($this->getRequest()->getParam('brands_ids') != null and $this->getRequest()->getParam('brands_ids') != 0) {
$brand_id = $this->getRequest()->getParam('brands_ids');
$condition = new Zend_Db_Expr("br.option_id = {$brand_id} AND br.product_ids = e.entity_id");
$this->_productCollection->getSelect()->join(array('br' => $this->_productCollection->getTable('shopbybrand/brand')), $condition, array('brand_id' => 'br.option_id'));
}
// join category
$condition = new Zend_Db_Expr("e.entity_id = ccp.product_id");
$condition2 = new Zend_Db_Expr("c.entity_id = ccp.category_id");
$this->_productCollection->getSelect()->join(array('ccp' => $this->_productCollection->getTable('catalog/category_product')), $condition, array())->join(array('c' => $this->_productCollection->getTable('catalog/category')), $condition2, array('cat_id' => 'c.entity_id'));
$condition = new Zend_Db_Expr("c.entity_id = cv.entity_id AND ea.attribute_id = cv.attribute_id");
// cutting corners here by hardcoding 3 as Category Entiry_type_id
$condition2 = new Zend_Db_Expr("ea.entity_type_id = 3 AND ea.attribute_code = 'name'");
$this->_productCollection->getSelect()->join(array('ea' => $this->_productCollection->getTable('eav/attribute')), $condition2, array())->join(array('cv' => $this->_productCollection->getTable('catalog/category') . '_varchar'), $condition, array('cat_name' => 'cv.value'));
$id = $this->getRequest()->getParam('id');
$this->_productCollection->getSelect()->where('c.entity_id = ?', $id)->limit(20);
}
return $this->_productCollection;
}
示例10: getItemsCollection
/**
* Retrieve quote items collection
*
* @param bool $loaded
* @return Mage_Eav_Model_Entity_Collection_Abstract
*/
public function getItemsCollection($useCache = true)
{
if (is_null($this->_items)) {
$this->_items = Mage::getModel('sales/quote_item')->getCollection();
$this->_items->setQuote($this);
}
return $this->_items;
}
示例11: _getProductCollection
/**
* Retrieve loaded category collection
*
* @return Mage_Eav_Model_Entity_Collection_Abstract
*/
protected function _getProductCollection()
{
if (is_null($this->_productCollection)) {
$layer = $this->getLayer();
/* @var $layer Mage_Catalog_Model_Layer */
if ($this->getShowRootCategory()) {
$this->setCategoryId(Mage::app()->getStore()->getRootCategoryId());
}
// if this is a product view page
if (Mage::registry('product')) {
// get collection of categories this product is associated with
$categories = Mage::registry('product')->getCategoryCollection()->setPage(1, 1)->load();
// if the product is associated with any category
if ($categories->count()) {
// show products from this category
$this->setCategoryId(current($categories->getIterator()));
}
}
$origCategory = null;
if ($this->getCategoryId()) {
$category = Mage::getModel('catalog/category')->load($this->getCategoryId());
if ($category->getId()) {
$origCategory = $layer->getCurrentCategory();
$layer->setCurrentCategory($category);
}
}
$this->_productCollection = $layer->getProductCollection();
// Start of Code to force Magento to numerically sort decimal attributes rather than alphabetically
if ($this->getRequest()->getParam('order')) {
$filterAttribute = $this->getRequest()->getParam('order');
} else {
$filterAttribute = 'website_special';
}
if ($this->getRequest()->getParam('dir')) {
$filterAttributeDir = $this->getRequest()->getParam('dir');
} else {
$filterAttributeDir = 'asc';
}
$attributeType = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', $filterAttribute)->getFrontendClass();
// If a Sort By option is selected on category page and attribute has frontend_class = validate-number or validate-digits
// then CAST the attribute values as signed integers
if (isset($filterAttribute) && ($attributeType == 'validate-digits' || $attributeType == 'validate-number')) {
$this->_productCollection->getSelect()->reset(Zend_Db_Select::ORDER);
$this->_productCollection->getSelect()->order('CAST(`' . $filterAttribute . '` AS SIGNED) ' . $filterAttributeDir . "'");
}
if ($this->getRequest()->getParam('q')) {
$q = $this->getRequest()->getParam('q');
//$this->_productCollection->getSelect()->where("name LIKE '%".$q."'%");
}
//echo $this->_productCollection->getSelect();
// End of code to force Magento to numerically sort....
$this->prepareSortableFieldsByCategory($layer->getCurrentCategory());
if ($origCategory) {
$layer->setCurrentCategory($origCategory);
}
}
return $this->_productCollection;
}
示例12: addItem
/**
* Add an object to the collection
*
* @param Varien_Object $object
* @return Mage_Eav_Model_Entity_Collection_Abstract
*/
public function addItem(Varien_Object $object)
{
if (get_class($object) !== $this->_itemObjectClass) {
throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('Attempt to add an invalid object'));
}
try {
return parent::addItem($object);
} catch (Exception $ex) {
}
}
示例13: getItemsCollection
/**
* Retrieve quote items collection
*
* @param bool $loaded
* @return Mage_Eav_Model_Entity_Collection_Abstract
*/
public function getItemsCollection($useCache = true)
{
if ($this->hasItemsCollection()) {
return $this->getData('items_collection');
}
if (is_null($this->_items)) {
$this->_items = Mage::getModel('buyback/quote_item')->getCollection();
$this->_items->setQuote($this);
}
return $this->_items;
}
示例14: _getPostCollection
/**
* Retrieve loaded category collection
*
* @return Mage_Eav_Model_Entity_Collection_Abstract
*/
protected function _getPostCollection()
{
if (is_null($this->_postCollection)) {
$this->_postCollection = Mage::getModel('vc_miniblog/post')->getCollection();
$this->_postCollection->getSelect()->columns(array('num_comment' => '(SELECT COUNT(*) FROM ' . Mage::getSingleton('core/resource')->getTableName('vc_miniblog/comment') . ' WHERE post_id = main_table.post_id)'));
$tag = $this->getRequest()->getParam('tag');
$cat = $this->getRequest()->getParam('cat');
if (strlen($tag) > 0) {
$this->_postCollection->addFieldToFilter('tags', array('like' => '%' . $tag . '%'));
}
if (strlen($cat) > 0) {
$select = new Zend_Db_Select(Mage::getSingleton('core/resource')->getConnection('read'));
$select->from(array('pc' => Mage::getSingleton('core/resource')->getTableName('vc_miniblog/post_category')), array('post_id'))->joinInner(array('c' => Mage::getSingleton('core/resource')->getTableName('vc_miniblog/category')), 'pc.category_id = c.category_id', array())->where('c.identifier = ?', $cat);
$this->_postCollection->addFieldToFilter('post_id', array('in' => new Zend_Db_Expr($select)));
}
$select2 = new Zend_Db_Select(Mage::getSingleton('core/resource')->getConnection('read'));
$select2->from(array('ps' => Mage::getSingleton('core/resource')->getTableName('vc_miniblog/post_store')), array('post_id'))->where('ps.store_id = ?', Mage::app()->getStore()->getId())->orWhere('ps.store_id = ?', 0);
$this->_postCollection->addFieldToFilter('post_id', array('in' => new Zend_Db_Expr($select2)));
}
return $this->_postCollection;
}
示例15: _construct
protected $_attributeFilterBlockName;
/**
* Price Filter Block Name
*
* @var string
*/
protected $_priceFilterBlockName;
/**
* Decimal Filter Block Name
*
* @var string
*/
protected $_decimalFilterBlockName;
/**
* Internal constructor
*/
protected function _construct()
{
parent::_construct();
$this->_initBlocks();
}
/**
* Initialize blocks names
*/
protected function _initBlocks()
{
$this->_stateBlockName = 'catalog/layer_state';
$this->_categoryBlockName = 'catalog/layer_filter_category';
$this->_attributeFilterBlockName = 'catalog/layer_filter_attribute';
$this->_priceFilterBlockName = 'catalog/layer_filter_price';
$this->_decimalFilterBlockName = 'catalog/layer_filter_decimal';
}
/**
* Retrieve loaded category collection
*
* @return Mage_Eav_Model_Entity_Collection_Abstract
*/
protected function _getProductCollection()
{
if (is_null($this->_productCollection)) {
$layer = $this->getLayer();