有没有办法在命令行上获取带有当前规范URL的产品列表?
原文链接:https://www.f2er.com/php/136830.htmlclass Mage_Shell_UrlTest extends Mage_Shell_Abstract { public function run() { $productCollection = Mage::getResourceModel('catalog/product_collection') ->addStoreFilter() ->addUrlRewrite() ->addAttributeToSelect('*') ->setPageSize(10) // just for testing ->addFieldToFilter('visibility',Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH) ->addAttributeToFilter('status',array( 'eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED )); Mage::getSingleton('cataloginventory/stock') ->addInStockFilterToCollection($productCollection); foreach ($productCollection as $product) { $url = $product->getUrlModel()->getUrl($product,array('_ignore_category' => true)); echo PHP_EOL . $url . PHP_EOL; // debug output } } } $shell = new Mage_Shell_UrlTest(); $shell->run();