Magento 코어 파일 New.php가 신제품을 블록으로 호출하는 방식을 변경하고 싶습니다.Magento 신제품 New.php를 날짜 대신 &를 사용하지 않고 id로 바꾸기
파일은 app/code/core/Mage/Catalog/Block/Product/New.php에 있습니다.이 파일을 업데이트로부터 보호하려면이 파일을 로컬 디렉토리로 복사했습니다. 관심의
내용은 다음과 같습니다
protected function _beforeToHtml()
{
$todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$collection = Mage::getResourceModel('catalog/product_collection');
$collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
$collection = $this->_addProductAttributesAndPrices($collection)
->addStoreFilter()
->addAttributeToFilter('news_from_date', array('or'=> array(
0 => array('date' => true, 'to' => $todayDate),
1 => array('is' => new Zend_Db_Expr('null')))
), 'left')
->addAttributeToFilter('news_to_date', array('or'=> array(
0 => array('date' => true, 'from' => $todayDate),
1 => array('is' => new Zend_Db_Expr('null')))
), 'left')
->addAttributeToFilter(
array(
array('attribute' => 'news_from_date', 'is'=>new Zend_Db_Expr('not null')),
array('attribute' => 'news_to_date', 'is'=>new Zend_Db_Expr('not null'))
)
)
->addAttributeToSort('news_from_date', 'desc')
->setPageSize($this->getProductsCount())
->setCurPage(1)
;
$this->setProductCollection($collection);
return parent::_beforeToHtml();
}
이 파일은 제품 관리자에서 New Product From
및 New Product To
날짜 필드의 선택적 항목 필드를 끌어으로 작동합니다. 이는 이러한 필드를 업데이트하는 데 필요한 카탈로그 및 수동 관리의 크기를 감안할 때 불편합니다. 따라서 기본적으로 MAX 제품 ID (즉, 가장 최근에 추가 된 제품)를 가져 와서 그 전에 100 개까지 실행되도록 기능을 변경하고 싶습니다. 상점에있는 가장 최근의 100 개의 제품이 표시됩니다.
나는 이것을 시도했지만 작동하지 않았다.
$collection = $this->_addProductAttributesAndPrices($collection)
->addStoreFilter()
->addAttributeToFilter ('entity_id')
->addAttributeToSort('entity_id', 'desc')
->setPageSize($this->getProductsCount())
->setCurPage(1)
;
$this->setProductCollection($collection);
return parent::_beforeToHtml();
}
이
단지 제품 ID (ENTITY_ID)하지만 아무것도 (이 중 어떤 PHP 오류를 포기하지 않았다) 반환 기반으로 제품을 반환하려고 시도했습니다.
네이 일! 감사. 항상 가장 간단한 것입니다. 난 단지 5 제품을 반환하는 그것과 함께 몇 가지 문제가 있었는데, 나는 XML을 변경하면 그것을 정렬거야. 고마워요! – James