Questions tagged «paths»

4
如何在phtml magento 2中获取根目录路径?
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface'); $mediaPath = $fileSystem->getDirectoryRead(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA)->getAbsolutePath(); 它返回媒体路径。如何在phtml页面中获取项目的根路径?


2
Magento 2:获取发布/静态文件路径
我需要获取文件夹中图像的文件PATHpub/static/[VENDOR_THEME]。 目前,我可以使用助手来做到这一点: public function __construct( \Magento\Framework\App\Helper\Context $context, \Magento\Framework\View\Asset\Repository $assetRepository, \Magento\Framework\App\Filesystem\DirectoryList $directoryList ) { parent::__construct($context); $this->_assetRepo = $assetRepository; $this->_directoryList = $directoryList; } public function getImagePath($image) { return $this->_directoryList->getPath(DirectoryList::STATIC_VIEW) . '/' . $this->_assetRepo->getStaticViewFileContext()->getPath() . '/' . $image; } 是否有内置的Magento函数可以处理此问题,所以我不必创建自己的帮助器?
9 magento2  paths 

5
Magento2:获取产品的图像路径
我创建了用于获取产品的自定义页面。我得到了所有信息,但是如何获得完整的图像路径。我正在使用getImage()它只显示图像如何获取完整路径。 <a href="<?php echo $this->getBaseUrl().$_item->getUrlKey();?>" title="<?php echo $_item->getName() ?>" class="product-image"><img src="<?php echo $this->getImage();?>" alt="<?php echo $_item->getName() ?>" />
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.