本文整理汇总了PHP中Mage_Catalog_Block_Product_List::_getProductCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Block_Product_List::_getProductCollection方法的具体用法?PHP Mage_Catalog_Block_Product_List::_getProductCollection怎么用?PHP Mage_Catalog_Block_Product_List::_getProductCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Block_Product_List
的用法示例。
在下文中一共展示了Mage_Catalog_Block_Product_List::_getProductCollection方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getProductCollection
/**
* Retrieve loaded category collection
*
* @return Mage_Eav_Model_Entity_Collection_Abstract
*/
protected function _getProductCollection()
{
if (is_null($this->_prodCollection)) {
$collection = parent::_getProductCollection();
/*Get customer "status" attribute options*/
$_approvedStatusId = Mage::getStoreConfig('marketplace/status/approved');
if ($_approvedStatusId) {
$_customerData = Mage::getModel('customer/customer')->getCollection()->addFieldToFilter('status', $_approvedStatusId)->load();
$where = 'ce.value IS NULL';
$_sellerIds = array();
/*Get array of seller ids with stats approved*/
foreach ($_customerData as $_data) {
$_sellerIds[] = $_data['entity_id'];
}
if ($_sellerIds) {
$where .= " OR ce.value in (" . implode(',', $_sellerIds) . ")";
}
$resource = Mage::getSingleton('core/resource');
$tableName = $resource->getTableName('catalog_product_entity_int');
$collection->getSelect()->joinLeft($tableName . ' As ce', 'ce.entity_id=e.entity_id AND ce.attribute_id=' . Mage::helper('marketplace')->getProductSellerAttributeId(), null);
$collection->getSelect()->where($where);
}
$this->_prodCollection = $collection;
}
return $this->_prodCollection;
}
示例2: _getProductCollection
public function _getProductCollection()
{
if ($this->getSkuList()) {
$collection = Mage::getModel('catalog/product')->getCollection();
$layer = $this->getLayer();
$layer->prepareProductCollection($collection);
} else {
$collection = parent::_getProductCollection();
}
if ($this->getLimit()) {
$collection->setPageSize($this->getLimit());
}
if ($this->getSortBy()) {
$collection->setOrder($this->getSortBy(), $this->getSortByDirection());
}
if ($this->getSkuList()) {
$select = $collection->getSelect();
$separator = $this->getSeparator();
if (empty($separator)) {
$separator = ',';
}
$skus = explode($separator, $this->getSkuList());
if (count($skus)) {
$select->where('e.sku IN (?)', $skus);
$escapedSkus = array();
foreach ($skus as $sku) {
$escapedSkus[] = $collection->getConnection()->quote($sku);
}
$select->order(new Zend_Db_Expr('FIELD(e.sku, ' . join(',', $escapedSkus) . ')'));
} else {
$select->where('SKU IS NULL');
}
}
return $collection;
}
示例3: _getProductCollection
/**
* Retrieve loaded category collection
*
* @return Mage_Eav_Model_Entity_Collection_Abstract
*/
protected function _getProductCollection()
{
$collection = parent::_getProductCollection();
/*
* Collections using Product Flat index require different processing.
*/
if (Mage::getStoreConfigFlag('catalog/frontend/flat_catalog_product')) {
$collection->getSelect()->where(new Zend_Db_Expr('price_index.final_price < price_index.price'));
} else {
$today = date('Y-m-d', time());
$collection->addAttributeToFilter('special_price', array('is' => new Zend_Db_Expr('not null')))->addAttributeToFilter('special_from_date', array('or' => array(0 => array('date' => true, 'to' => $today), 1 => array('is' => new Zend_Db_Expr('null')))), 'left')->addAttributeToFilter('special_to_date', array('or' => array(0 => array('date' => true, 'from' => $today), 1 => array('is' => new Zend_Db_Expr('null')))), 'left');
}
return $collection;
}
示例4: _getProductCollection
/**
* Retrieve loaded category collection
*
* @return Mage_Eav_Model_Entity_Collection_Abstract
*/
protected function _getProductCollection()
{
$judet = Mage::app()->getRequest()->getParam('judet');
if ($judet) {
$collection = parent::_getProductCollection()->clear();
foreach ($collection as $key => $product) {
if ($judet && strpos($product->getOfgZonaPersonalizata(), $judet) === false) {
$collection->removeItemByKey($key);
}
}
$this->_productCollection = $collection;
return $this->_productCollection;
}
return parent::_getProductCollection();
}
示例5: _getProductCollection
protected function _getProductCollection()
{
$profileCollection = Mage::getModel('cartmart/profile')->getCollection();
$profileCollection->getSelect()->reset(Zend_Db_Select::COLUMNS)->columns('user_id');
$userIds = $profileCollection->toArray(array('user_id'));
$userCollection = Mage::getModel('admin/user')->getCollection()->addFieldToFilter('is_active', 1);
if ($userIds['totalRecords'] != 0) {
$userCollection->addFieldToFilter('user_id', array('in' => $userIds));
}
$userIds = $userCollection->getAllIds();
$collection = parent::_getProductCollection();
$collection->addAttributeToSelect('vendor')->addAttributeToFilter('vendor', array(array('in' => $userIds), array('null' => true)));
if ($this->getRequest()->getRouteName() == 'cartmart' && $this->getRequest()->getControllerName() == 'vendor' && $this->getRequest()->getActionName() == 'items') {
$profileId = $this->getRequest()->getParam('id');
if (isset($profileId)) {
$vendorId = Mage::getModel('cartmart/profile')->load($profileId)->getUserId();
$collection->addAttributeToSelect('vendor')->addAttributeToFilter('vendor', $vendorId);
}
}
return $collection;
}
示例6: _getProductCollection
protected function _getProductCollection()
{
$params = $this->getRequest()->getParams();
$action = Mage::app()->getRequest()->getActionName();
// could be: index, foto, video or foto-video
if (is_null($this->_productCollection)) {
$collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('furnizor_account_status', 1)->addAttributeToFilter('furnizor_account_online_status', 1);
// add region filter to collection
if (isset($params['judet'])) {
$collection->addAttributeToFilter('furnizor_location_province', $params['judet']);
unset($params['judet'], $params['p']);
}
/*
* aplly layer filters to collection
* take a look into Picode_ConturiFurnizori_Block_Conturi_Layer
*/
foreach ($params as $key => $val) {
$attributeCode = $this->convertAttributeLabeToCode($key);
$collection->addAttributeToFilter($attributeCode, $val);
}
// add service type filter to collection
switch ($action) {
case 'foto':
$collection->addAttributeToFilter('furnizor_company_services', 1);
break;
case 'video':
$collection->addAttributeToFilter('furnizor_company_services', 2);
break;
case 'fotovideo':
$collection->addAttributeToFilter('furnizor_company_services', 3);
break;
}
//Zend_Debug::dump($collection->getData()); die();
//$collection->setOrder('business_images_logo', 'DESC');
$this->_productCollection = $collection;
}
return parent::_getProductCollection();
}
示例7: _getProductCollection
protected function _getProductCollection()
{
// trying to override this method
if (is_null($this->_x_productCollection)) {
$collection = parent::_getProductCollection();
$session = Mage::getSingleton('customer/session');
$isCorporate = FALSE;
if ($session->isLoggedIn()) {
$customer = $session->getCustomer();
$isCorporate = $customer->getZiscorporate();
}
if ($isCorporate == 470) {
$collection->addTierPriceData();
$collection->addAttributeToFilter('tier_price', 'notnull');
// $collection->getSelect()->where("price_index.tier_price IS NOT NULL");
Mage::Log("Rrap_Corporate_Block_Product_List select is " . $collection->getSelect());
}
$this->_productCollection = $collection;
} else {
$collection = parent::_getProductCollection();
}
return $collection;
}
示例8: getProductCollection
//.........这里部分代码省略.........
$i++;
}
}
}
$field_condition = str_replace($a->field, $a->field . '_table.value', $field_condition);
foreach ($tmp as $key => $t) {
$field_condition = str_replace($this->encrypt . $key, $t, $field_condition);
}
// echo $field_condition ;
$field_widget .= '"' . $a->field . '",';
}
$field_widget = substr($field_widget, 0, strlen($field_widget) - 1) . ')';
$dem = 0;
//Join if use catalog flat
$products->getSelect()->join(array('entity_table' => 'catalog_product_entity'), 'e.entity_id=entity_table.entity_id', array());
foreach ($array_field as $a) {
$field = $a->field;
$eavAttribute = Mage::getResourceSingleton('catalog/product')->getAttribute($field);
//->getData('frontend_input');
$backendType = $eavAttribute->getBackend()->getTable();
$frontendInput = $eavAttribute->getData('frontend_input');
if ($dem == count($array_field) - 1) {
if ($frontendInput == 'select') {
$products->getSelect()->join(array('cat_table' => $backendType), 'cat_table.entity_id=entity_table.entity_id
AND cat_table.store_id=0
AND cat_table.attribute_id=' . $eavAttribute->getData('attribute_id') . '
AND cat_table.entity_type_id=entity_table.entity_type_id
INNER JOIN eav_attribute_option_value as ' . $field . '_table
ON cat_table.value=' . $field . '_table.option_id
AND cat_table.store_id=' . $field . '_table.store_id and (' . $field_condition . ')', array($field => $field . '_table.value'));
} else {
$products->getSelect()->join(array($field . '_table' => $backendType), $field . '_table.entity_id=entity_table.entity_id
AND ' . $field . '_table.store_id=0
AND ' . $field . '_table.attribute_id=' . $eavAttribute->getData('attribute_id') . '
AND ' . $field . '_table.entity_type_id=entity_table.entity_type_id and (' . $field_condition . ')', array($field => $field . '_table.value'));
}
} else {
if ($frontendInput == 'select') {
$products->getSelect()->join(array('cat_table' => $backendType), 'cat_table.entity_id=entity_table.entity_id
AND cat_table.store_id=0
AND cat_table.attribute_id=' . $eavAttribute->getData('attribute_id') . '
AND cat_table.entity_type_id=entity_table.entity_type_id
INNER JOIN eav_attribute_option_value as ' . $field . '_table
ON cat_table.value=' . $field . '_table.option_id
AND cat_table.store_id=' . $field . '_table.store_id', array($field => $field . '_table.value'));
} else {
$products->getSelect()->join(array($field . '_table' => $backendType), $field . '_table.entity_id=entity_table.entity_id
AND ' . $field . '_table.store_id=0
AND ' . $field . '_table.attribute_id=' . $eavAttribute->getData('attribute_id') . '
AND ' . $field . '_table.entity_type_id=entity_table.entity_type_id', array($field => $field . '_table.value'));
}
}
$dem++;
}
}
if ($_SERVER['REMOTE_ADDR'] == '72.209.195.124' || $_SERVER['REMOTE_ADDR'] == '72.209.195.124' || $_SERVER['REMOTE_ADDR'] == '72.209.195.124') {
echo $products->getSelect();
echo $this->getData('order_by');
}
//ashwani bhasin 7-31-2012 to fix the page not picking up pagesize from memory. commented the above line and replaced it with below
$limit = Mage::getSingleton('catalog/session')->getLimitPage();
if (!$limit) {
$limit = '40';
}
// echo $limit;
$pageSize = $this->getRequest()->getParam('limit');
if (!$pageSize) {
$pageSize = $limit;
}
//echo $pageSize;
if (count($orders)) {
$products->addAttributeToSort($orders[0], $orders[1]);
}
$products->addAttributeToSort('mysort', 'desc');
if (isset($pageSize)) {
$products->setPageSize($pageSize);
}
$products->setCurPage($this->getRequest()->getParam('p', 1));
$products->addAttributeToSelect('*');
//echo $pageSize;
//print_r($products->getData());exit;
//echo (string)($products->getSelect());exit;
// print_r(count($products->getData()));exit;
//echo $pageSize;exit;
/*foreach ($products as $s)
print_r($s->getCategoryIds());die;
*/
$this->setCollection($products);
//$toolbar = $this->getLayout()->createBlock('catalog/product/list/toolbar', microtime());
//$toolbar->setCollection($products);
//$this->setChild('toolbar', $toolbar);
//echo $toolbar->getChildHtml();exit;
//print_r($this->_productCollection->getData());
//$this->_productCollection = $products;
//print_r($this->getToolbarHtml());exit;
$this->setSize(count($this->_productCollection->getData()));
//echo $this->getSize();exit;
parent::_getProductCollection();
return $this->_productCollection;
}
示例9: _getProductCollection
/**
* (non-PHPdoc)
* @see Mage_Catalog_Block_Product_List::_getProductCollection()
*/
protected function _getProductCollection()
{
$productCollection = parent::_getProductCollection();
$productCollection->addAttributeToSelect('sm_product_vendor_id')->addFieldToFilter('sm_product_vendor_id', $this->getVendor()->getId());
return $productCollection;
}
示例10: _getProductCollection
/**
* Retrieve loaded category collection
*
* @return Mage_Eav_Model_Entity_Collection_Abstract
*/
protected function _getProductCollection()
{
if (is_null($this->_productCollection)) {
$toolbar = $this->getToolbarBlock();
$orderby = $toolbar->getCurrentOrder();
$direction = $toolbar->getCurrentDirection();
$documents = array();
if (isset($this->_solrData['response']['docs'])) {
$documents = $this->_solrData['response']['docs'];
}
$session = Mage::getSingleton('customer/session');
$isCorporate = FALSE;
if ($session->isLoggedIn()) {
$customer = $session->getCustomer();
$isCorporate = $customer->getZiscorporate();
}
if ($isCorporate == 470) {
$collection = Mage_Catalog_Block_Product_List::_getProductCollection();
$collection->getSelect()->where("price_index.tier_price IS NOT NULL");
$productIds = array();
foreach ($collection as $product) {
$productIds[] = $product->getId();
}
} else {
$productIds = array();
if (is_array($documents) && count($documents) > 0) {
foreach ($documents as $_doc) {
if (isset($_doc['products_id'])) {
$productIds[] = $_doc['products_id'];
}
}
}
/*$catId = Mage::getModel('catalog/layer')->getCurrentCategory()->getId();
if($catId == '222' && count($productIds) < 40){
array_push($productIds, "47078","47079","47080");
}*/
}
$store = Mage::app()->getStore();
$collection = Mage::getModel('catalog/product')->getCollection();
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
$collection->addAttributeToFilter('entity_id', array('in' => $productIds));
if ($isCorporate != 470) {
$collection->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds())->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInSearchIds());
}
$checkInstockConfig = Mage::helper('solrsearch')->getSetting('check_instock');
if (intval($checkInstockConfig) > 0) {
if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
$collection->joinField('qty', 'cataloginventory/stock_item', 'qty', 'product_id=entity_id', '{{table}}.stock_id=1', 'left');
}
}
$collection->getSelect()->order("find_in_set(e.entity_id,'" . implode(',', $productIds) . "')");
/*
if (empty($orderby) || $orderby == 'position'){
$collection->getSelect()->order("find_in_set(e.entity_id,'".implode(',',$productIds)."')");
}else{
$collection->addAttributeToSort($orderby, strtoupper($direction));
}*/
$this->_productCollection = $collection;
}
return $this->_productCollection;
}