本文整理汇总了PHP中Mage_Catalog_Model_Resource_Product_Collection类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Resource_Product_Collection类的具体用法?PHP Mage_Catalog_Model_Resource_Product_Collection怎么用?PHP Mage_Catalog_Model_Resource_Product_Collection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Catalog_Model_Resource_Product_Collection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _process
/**
* @param Mage_Catalog_Model_Resource_Product_Collection $products
* @return bool
*/
protected function _process($products)
{
$processor = $this->_htmlProcessor;
$helper = $this->_getHelper();
foreach ($products as $product) {
$product->setData('url', $product->getProductUrl());
}
$items = $processor->query($helper->getCssSelector('related_product_link'));
if (count($items) === 0) {
return false;
}
$positions = array();
foreach ($items as $i => $item) {
/** @var $item DOMElement */
$url = $item->getAttribute('href');
$product = $products->getItemByColumnValue('url', $url);
if (!$product) {
continue;
}
if ($helper->isEnabledForProduct($product)) {
$positions[] = $i;
}
}
$processor->replace($helper->getCssSelector('related_product_price'), $this->_getHelper()->prepareReplacement(), $positions);
}
开发者ID:CE-Webmaster,项目名称:CE-Hub,代码行数:29,代码来源:Related.php
示例2: _filterPrice
/**
* Callback method for applying price filter.
* @param Mage_Catalog_Model_Resource_Product_Collection $_collection
* @param Mage_Adminhtml_Block_Widget_Grid_Column $_column
*/
public function _filterPrice($_collection, $_column)
{
$_field = $_column->getFilterIndex() ? $_column->getFilterIndex() : $_column->getIndex();
$_condition = $_column->getFilter()->getCondition();
if (!$_field || !is_array($_condition)) {
return;
}
if (!array_key_exists('type', $_condition) || !is_numeric($_condition['type'])) {
$_collection->addFieldToFilter($_field, $_condition);
} else {
$_storeId = (int) $this->getRequest()->getParam('store', 0);
$_store = Mage::app()->getStore($_storeId);
$_joinCondition = array('`e`.`entity_id` = `at_reservation_price`.`entity_id`', '`at_reservation_price`.`store_id` = ' . $_store->getId(), '`at_reservation_price`.`ptype` = ' . $_condition['type']);
if (array_key_exists('from', $_condition)) {
$_joinCondition[] = '`at_reservation_price`.`price` >= ' . $_condition['from'];
}
if (array_key_exists('to', $_condition)) {
$_joinCondition[] = '`at_reservation_price`.`price` <= ' . $_condition['to'];
}
$_joinCondition[] = '`at_reservation_price`.`date_from` = \'0000-00-00 00:00:00\' OR DATE(`at_reservation_price`.`date_from`) <= DATE(\'' . date('Y-m-d H:i:s', Mage::getModel('core/date')->gmtTimestamp(time())) . '\')';
$_joinCondition[] = '`at_reservation_price`.`date_to` = \'0000-00-00 00:00:00\' OR DATE(`at_reservation_price`.`date_to`) >= DATE(\'' . date('Y-m-d H:i:s', Mage::getModel('core/date')->gmtTimestamp(time())) . '\')';
$_collection->getSelect()->joinInner(array('at_reservation_price' => $_collection->getTable('payperrentals/reservationprices')), '(' . implode(') AND (', $_joinCondition) . ')', array('price_type' => 'at_reservation_price.ptype', 'reservation_price' => 'at_reservation_price.price', 'reservation_number' => 'at_reservation_price.numberof'));
/** TODO Check collection count calculation with group. I think need change join for use distinct */
$_collection->getSelect()->group('e.entity_id');
}
}
开发者ID:hueyl77,项目名称:fourwindsgear,代码行数:31,代码来源:Price.php
示例3: addIsInStockFilterToCollection
/**
* Add only is in stock products filter to product collection
*
* @param Mage_Catalog_Model_Resource_Product_Collection $collection
*
* @return Mage_CatalogInventory_Model_Resource_Stock_Status
*/
public function addIsInStockFilterToCollection($collection)
{
$websiteId = Mage::app()->getStore($collection->getStoreId())->getWebsiteId();
$joinCondition = $this->_getReadAdapter()->quoteInto('e.entity_id = status_table_mli.product_id' . ' AND status_table_mli.store_id = ?', Mage::app()->getStore()->getId());
$collection->getSelect()->join(array('status_table_mli' => $this->getTable('demac_multilocationinventory/stock_status_index')), $joinCondition, array())->where('status_table_mli.is_in_stock=1');
return $this;
}
开发者ID:googlygoo,项目名称:Magento-Multi-Location-Inventory,代码行数:14,代码来源:Status.php
示例4: addExcludeProductFilter
/**
* Make collection not to load products that are in specified quote
*
* @param Mage_Catalog_Model_Resource_Product_Collection $collection
* @param int $quoteId
* @return Mage_Checkout_Model_Resource_Cart
*/
public function addExcludeProductFilter($collection, $quoteId)
{
$adapter = $this->_getReadAdapter();
$exclusionSelect = $adapter->select()->from($this->getTable('sales/quote_item'), array('product_id'))->where('quote_id = ?', $quoteId);
$condition = $adapter->prepareSqlCondition('e.entity_id', array('nin' => $exclusionSelect));
$collection->getSelect()->where($condition);
return $this;
}
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:15,代码来源:Cart.php
示例5: addCatalogInventoryToProductCollection
/**
* Add join for catalog in stock field to product collection
*
* @param Mage_Catalog_Model_Resource_Product_Collection $productCollection
* @return Mage_CatalogInventory_Model_Resource_Stock_Item
*/
public function addCatalogInventoryToProductCollection($productCollection)
{
$adapter = $this->_getReadAdapter();
$isManageStock = (int) Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK);
$stockExpr = $adapter->getCheckSql('cisi.use_config_manage_stock = 1', $isManageStock, 'cisi.manage_stock');
$stockExpr = $adapter->getCheckSql("({$stockExpr} = 1)", 'cisi.is_in_stock', '1');
$productCollection->joinTable(array('cisi' => 'cataloginventory/stock_item'), 'product_id=entity_id', array('is_saleable' => new Zend_Db_Expr($stockExpr), 'inventory_in_stock' => 'is_in_stock'), null, 'left');
return $this;
}
开发者ID:okite11,项目名称:frames21,代码行数:15,代码来源:Item.php
示例6: addMinimalPrices
public function addMinimalPrices(Mage_Catalog_Model_Resource_Product_Collection $collection)
{
$minimalPrices = $this->_getResource()->getMinimalPrices($collection->getLoadedIds());
foreach ($minimalPrices as $row) {
$item = $collection->getItemById($row['entity_id']);
if ($item) {
$item->setData('minimal_price', $row['value']);
$item->setData('minimal_tax_class_id', $row['tax_class_id']);
}
}
}
开发者ID:cewolf2002,项目名称:magento,代码行数:11,代码来源:Price.php
示例7: _beforeLoad
/**
* Add tax class id attribute to select and join price rules data if needed
*
* @return Mage_Catalog_Model_Resource_Product_Collection
*/
protected function _beforeLoad()
{
if (isset($this->_productLimitationFilters['category_id']) && is_array($this->_productLimitationFilters['category_id'])) {
$this->getSelect()->group('e.entity_id');
}
return parent::_beforeLoad();
}
开发者ID:kumardhirendra1,项目名称:Magento_Filter,代码行数:12,代码来源:Collection.php
示例8: apply
/**
* @param Mage_Catalog_Model_Resource_Product_Collection $collection
* @param string $currDir
*
* @return $this
*/
public function apply($collection, $currDir)
{
if (!$this->isEnabled()) {
return $this;
}
$alias = 'price_index';
if (preg_match('/`([a-z0-9\\_]+)`\\.`final_price`/', $collection->getSelect()->__toString(), $m)) {
$alias = $m[1];
}
$price = Mage::getStoreConfig('amsorting/general/profit_price');
$attribute = Mage::getStoreConfig('amsorting/general/product_attribute');
$collection->joinAttribute('cost', Mage_Catalog_Model_Product::ENTITY . '/' . $attribute, 'entity_id', null, 'left', Mage::app()->getStore()->getId());
$collection->getSelect()->columns(array('profit' => "(`{$alias}`.`{$price}` - IF(`at_cost`.`value` IS NULL, 0, `at_cost`.`value`))"));
$collection->getSelect()->order("profit {$currDir}");
return $this;
}
开发者ID:rcclaudrey,项目名称:dev,代码行数:22,代码来源:Profit.php
示例9: sort
/**
* @param Mage_Catalog_Model_Resource_Product_Collection $productCollection
* @return mixed
*/
public function sort(Mage_Catalog_Model_Resource_Product_Collection $productCollection)
{
//Pass a small validation
if (!$this->_getHelper()->isCategorySortingEnable() || $productCollection->getFlag(self::MARKETO_SORTED)) {
return $productCollection;
}
$categoriesList = $this->_getPesonalizeCalculator()->getScoreCategoryParams(HooshMarketing_Marketo_Model_Personalize_Calculator::CATEGORY_ID_AND_SCORE);
//get List of categories with key -> Category_id and value - Score
if (!count($categoriesList)) {
//if we havn`t score categories do nothing
return $productCollection;
}
uasort($categoriesList, function ($f, $s) {
return $f > $s ? 1 : -1;
//sort by descending
});
//Sort categories in order to show top scored categories first
$categoriesList = array_keys($categoriesList);
// get only category ids
try {
$productCategoryTable = $this->_getCoreResource()->getTableName("catalog_category_product");
$productCollection->getSelect()->joinLeft(array("marketo_category_table" => $productCategoryTable), "marketo_category_table.product_id = e.entity_id", array("top_category_id" => "marketo_category_table.category_id"))->group("entity_id")->order("FIELD(top_category_id, " . implode(',', $categoriesList) . ") DESC");
//order by top
$productCollection->setFlag(self::MARKETO_SORTED, true);
//to set order only one time
} catch (Exception $e) {
Mage::logException($e);
}
return $productCollection;
}
开发者ID:sereban,项目名称:magento-marketo-integration,代码行数:34,代码来源:Sorting.php
示例10: _applyCategoryFilter
/**
* Apply filter by category id
*
* @param Mage_Catalog_Model_Resource_Product_Collection $collection
*/
protected function _applyCategoryFilter(Mage_Catalog_Model_Resource_Product_Collection $collection)
{
$categoryId = $this->getRequest()->getParam('category_id');
if ($categoryId) {
$category = $this->_getCategoryById($categoryId);
if (!$category->getId()) {
$this->_critical('Category not found.', Mage_Api2_Model_Server::HTTP_BAD_REQUEST);
}
$collection->addCategoryFilter($category);
}
}
开发者ID:cewolf2002,项目名称:magento,代码行数:16,代码来源:Rest.php
示例11: apply
/**
* @param Mage_Catalog_Model_Resource_Product_Collection $collection
* @param string $currDir
*
* @return $this
*/
public function apply($collection, $currDir)
{
if (!$this->isEnabled()) {
return $this;
}
$sorters = $this->getSorters();
if (Mage::getStoreConfig('amsorting/general/use_index')) {
foreach ($sorters as $sorter) {
$collection->joinField($sorter->getCode(), $sorter->getIndexTable(), $sorter->getCode(), 'id=entity_id', array('store_id' => Mage::app()->getStore()->getId()), 'left');
}
} else {
$select = $collection->getSelect();
$col = $select->getPart('columns');
foreach ($sorters as $sorter) {
$col[] = array('', $sorter->getColumnSelect(), $sorter->getCode());
}
$select->setPart('columns', $col);
}
$collection->getSelect()->order(new Zend_Db_Expr('(' . $sorters['dividend']->getCode() . '/' . $sorters['divider']->getCode() . ') ' . $currDir));
return $this;
}
开发者ID:rcclaudrey,项目名称:dev,代码行数:27,代码来源:Orderview.php
示例12: getLinkCollection
/**
* Get link collection
*
* @return Mage_Catalog_Model_Resource_Product_Collection|null
*/
public function getLinkCollection()
{
if (is_null($this->_linkCollection)) {
$this->_linkCollection = $this->_getTargetLinkCollection();
if ($this->_linkCollection) {
// Perform rotation mode
$select = $this->_linkCollection->getSelect();
$rotationMode = $this->getTargetRuleHelper()->getRotationMode($this->getProductListType());
if ($rotationMode == Enterprise_TargetRule_Model_Rule::ROTATION_SHUFFLE) {
Mage::getResourceSingleton('enterprise_targetrule/index')->orderRand($select);
} else {
$select->order('link_attribute_position_int.value ASC');
}
}
}
return $this->_linkCollection;
}
开发者ID:QiuLihua83,项目名称:magento-enterprise-1.13.1.0,代码行数:22,代码来源:Abstract.php
示例13: _addProductAttributesAndPrices
/**
* Add all attributes and apply pricing logic to products collection
* to get correct values in different products lists.
* E.g. crosssells, upsells, new products, recently viewed
*
* @param Mage_Catalog_Model_Resource_Product_Collection $collection
* @return Mage_Catalog_Model_Resource_Product_Collection
*/
protected function _addProductAttributesAndPrices(Mage_Catalog_Model_Resource_Product_Collection $collection)
{
$test = Mage::getSingleton('catalog/config')->getProductAttributes();
return $collection->addMinimalPrice()->addFinalPrice()->addTaxPercents()->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->addUrlRewrite();
}
开发者ID:quanghuynt93,项目名称:VesSmartshop,代码行数:13,代码来源:Widget.php
示例14: addLowStockFilter
/**
* Add low stock filter to product collection
*
* @param Mage_Catalog_Model_Resource_Product_Collection $collection
* @param array $fields
* @return Mage_CatalogInventory_Model_Resource_Stock
*/
public function addLowStockFilter(Mage_Catalog_Model_Resource_Product_Collection $collection, $fields)
{
$this->_initConfig();
$adapter = $collection->getSelect()->getAdapter();
$qtyIf = $adapter->getCheckSql('invtr.use_config_notify_stock_qty', $this->_configNotifyStockQty, 'invtr.notify_stock_qty');
$conditions = array(array($adapter->prepareSqlCondition('invtr.use_config_manage_stock', 1), $adapter->prepareSqlCondition($this->_isConfigManageStock, 1), $adapter->prepareSqlCondition('invtr.qty', array('lt' => $qtyIf))), array($adapter->prepareSqlCondition('invtr.use_config_manage_stock', 0), $adapter->prepareSqlCondition('invtr.manage_stock', 1)));
$where = array();
foreach ($conditions as $k => $part) {
$where[$k] = join(' ' . Zend_Db_Select::SQL_AND . ' ', $part);
}
$where = $adapter->prepareSqlCondition('invtr.low_stock_date', array('notnull' => true)) . ' ' . Zend_Db_Select::SQL_AND . ' ((' . join(') ' . Zend_Db_Select::SQL_OR . ' (', $where) . '))';
$collection->joinTable(array('invtr' => 'cataloginventory/stock_item'), 'product_id = entity_id', $fields, $where);
return $this;
}
开发者ID:quyip8818,项目名称:Mag,代码行数:21,代码来源:Stock.php
示例15: _beforeLoad
/**
* Handles collection filtering by ids retrieves from search engine.
* Will also stores faceted data and total records.
*
* @return Mage_Catalog_Model_Resource_Product_Collection
*/
protected function _beforeLoad()
{
$this->_prepareQuery();
$ids = array();
if (!empty($this->_facets)) {
$this->getSearchEngineQuery()->resetFacets();
}
$result = $this->getSearchEngineQuery()->search();
$ids = isset($result['ids']) ? $result['ids'] : array();
if (isset($result['facets'])) {
$this->_facets = array_merge($this->_facets, $result['facets']);
}
$this->_totalRecords = isset($result['total_count']) ? $result['total_count'] : null;
$this->_isSpellChecked = $this->getSearchEngineQuery()->isSpellchecked();
if (empty($ids)) {
$ids = array(0);
// Fix for no result
}
$this->addIdFilter($ids);
$this->_searchedEntityIds = $ids;
$this->_pageSize = false;
return parent::_beforeLoad();
}
开发者ID:diglin,项目名称:smile-magento-elasticsearch,代码行数:29,代码来源:Collection.php
示例16: testSetOrder
/**
* @dataProvider setOrderDataProvider
*/
public function testSetOrder($order, $expectedOrder)
{
$this->_collection->setOrder($order);
$this->_collection->load();
// perform real SQL query
$selectOrder = $this->_collection->getSelect()->getPart(Zend_Db_Select::ORDER);
foreach ($expectedOrder as $field) {
$orderBy = array_shift($selectOrder);
$this->assertArrayHasKey(0, $orderBy);
$this->assertTrue(false !== strpos($orderBy[0], $field), 'Ordering by same column more than once is restricted by multiple RDBMS requirements.');
}
}
开发者ID:natxetee,项目名称:magento2,代码行数:15,代码来源:CollectionTest.php
示例17: addItem
/**
* Added exception handling to addItem, otherwise in some cases will throw an exception
*
* @param \Varien_Object $object
*/
public function addItem(\Varien_Object $object)
{
try {
return parent::addItem($object);
} catch (Exception $e) {
}
}
开发者ID:Emulator000,项目名称:magento-configurable-simple,代码行数:12,代码来源:Collection.php
示例18: addAttributeToSort
public function addAttributeToSort($attribute, $dir = self::SORT_ORDER_ASC)
{
if ($attribute == 'best') {
$this->getSelect()->order("t2.position " . $dir);
return $this;
}
return parent::addAttributeToSort($attribute, $dir);
}
开发者ID:TusharKDonda,项目名称:maruti,代码行数:8,代码来源:Collection.php
示例19: addAttributeToSort
/**
* Add attribute to sort
*
* @param string $attribute
* @param string $dir
* @return Mage_Reports_Model_Resource_Review_Product_Collection
*/
public function addAttributeToSort($attribute, $dir = self::SORT_ORDER_ASC)
{
if (in_array($attribute, array('review_cnt', 'last_created', 'avg_rating', 'avg_rating_approved'))) {
$this->getSelect()->order($attribute . ' ' . $dir);
return $this;
}
return parent::addAttributeToSort($attribute, $dir);
}
开发者ID:evinw,项目名称:project_bloom_magento,代码行数:15,代码来源:Collection.php
示例20: setOrder
/**
* Set Order field
*
* @param string $attribute
* @param string $dir
* @return Mage_CatalogSearch_Model_Resource_Fulltext_Collection
*/
public function setOrder($attribute, $dir = 'desc')
{
if ($attribute == 'relevance') {
//$this->getSelect()->order("relevance {$dir}");
} else {
parent::setOrder($attribute, $dir);
}
return $this;
}
开发者ID:axovel,项目名称:easycarcare,代码行数:16,代码来源:Collection.php
注:本文中的Mage_Catalog_Model_Resource_Product_Collection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论