简体   繁体   English

Magento 1.9-Media.phtml内容未加载到我的可配置产品查看页面中

[英]Magento 1.9 - Media.phtml content not loading in my configurable products view page

I have recently been learning the ways of magento, and up until two days ago it was all going great, but then I started learning about different product types .eg Simple, Bundle, Configurable. 我最近一直在学习magento的方法,直到两天前一切都很好,但是后来我开始学习不同的产品类型,例如简单,捆绑销售,可配置。 So anyway i needed to create a configurable product for a plain t-shirt, which had an option for colour and size. 因此,无论如何,我需要为一件普通的T恤衫创建一个可配置的产品,并可以选择颜色和尺寸。 I added the image as i would any other product and made sure it was in-stock and done everything i would have done with a simple product, assigned the simple products and everything seemed fine. 我像添加其他任何产品一样添加了图像,并确保它有库存,并完成了使用简单产品可以完成的所有工作,分配了简单产品,一切看起来都很好。 So i went on to my front end and it shows fine in the category page which its in but when i go to the actual viewing page for the product the Media.phtml file seems to be missing. 因此,我继续进行前端操作,它在其所属的类别页面中显示良好,但是当我转到产品的实际查看页面时,Media.phtml文件似乎丢失了。 The main image isn't there and inside the product-img-box div there seems to be nothing there (where my media loads for every other product). 主图像不存在,并且在product-img-box div中似乎没有任何内容(我的媒体在其中加载了其他所有产品)。

Any help would be appreciated, i have searched everywhere for some sort of answer but haven't found a thing. 任何帮助将不胜感激,我到处都在寻找某种答案,但没有发现任何东西。

Thanks in advance, Josh. 预先感谢,乔希。

Below is the code of my product/view.phtml page: 以下是我的product / view.phtml页面的代码:

<?php $_helper = $this->helper('catalog/output'); ?>
<?php $_product = $this->getProduct(); ?>
<script type="text/javascript">
    var optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);
</script>
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
<div class="product-view">
    <div class="product-essential">
    <form action="<?php echo $this->getSubmitUrl($_product) ?>" method="post"         id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
        <?php echo $this->getBlockHtml('formkey') ?>
        <div class="no-display">
            <input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
            <input type="hidden" name="related_product" id="related-products-field" value="" />
        </div>

        <div class="product-shop">
            <div class="product-name">
                <h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1>
            </div>

            <?php if ($this->canEmailToFriend()): ?>
                <p class="email-friend"><a href="<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>"><?php echo $this->__('Email to a Friend') ?></a></p>
            <?php endif; ?>

            <?php echo $this->getReviewsSummaryHtml($_product, false, true)?>



            <?php if ($_product->getShortDescription()):?>
                <div class="short-description">
                    <h2><?php echo $this->__('Overview') ?></h2>
                    <div class="std"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div>
                </div>
            <?php endif;?>

            <?php echo $this->getChildHtml('other');?>

            <?php if ($_product->isSaleable() && $this->hasOptions()):?>
                <?php echo $this->getChildChildHtml('container1', '', true, true) ?>
            <?php endif;?>

        </div>

        <div class="product-img-box">
            <?php echo $this->getChildHtml('alert_urls') ?>
            <?php echo $this->getChildHtml('product_type_data') ?>
            <?php echo $this->getTierPriceHtml() ?>
            <?php echo $this->getChildHtml('extrahint') ?>
                <?php if (!$this->hasOptions()):?>
                    <div class="add-to-box">
                        <?php if($_product->isSaleable()): ?>
                            <?php echo $this->getChildHtml('addtocart') ?>
                            <?php if( $this->helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?>
                            <?php endif; ?>
                        <?php endif; ?>
                    </div>
            <?php echo $this->getChildHtml('media') ?>

                <?php echo $this->getChildHtml('extra_buttons') ?>
            <?php elseif (!$_product->isSaleable()): ?>
                <div class="add-to-box">
                    <?php echo $this->getChildHtml('addto') ?>
                </div>
            <?php endif; ?>
        </div>

        <div class="clearer"></div>
        <?php if ($_product->isSaleable() && $this->hasOptions()):?>
            <?php echo $this->getChildChildHtml('container2', '', true, true) ?>
        <?php endif;?>
    </form>
    <script type="text/javascript">
    //<![CDATA[
        var productAddToCartForm = new VarienForm('product_addtocart_form');
        productAddToCartForm.submit = function(button, url) {
            if (this.validator.validate()) {
                var form = this.form;
                var oldUrl = form.action;

                if (url) {
                   form.action = url;
                }
                var e = null;
                try {
                    this.form.submit();
                } catch (e) {
                }
                this.form.action = oldUrl;
                if (e) {
                    throw e;
                }

                if (button && button != 'undefined') {
                    button.disabled = true;
                }
            }
        }.bind(productAddToCartForm);

        productAddToCartForm.submitLight = function(button, url){
            if(this.validator) {
                var nv = Validation.methods;
                delete Validation.methods['required-entry'];
                delete Validation.methods['validate-one-required'];
                delete Validation.methods['validate-one-required-by-name'];
                // Remove custom datetime validators
                for (var methodName in Validation.methods) {
                    if (methodName.match(/^validate-datetime-.*/i)) {
                        delete Validation.methods[methodName];
                    }
                }

                if (this.validator.validate()) {
                    if (url) {
                        this.form.action = url;
                    }
                    this.form.submit();
                }
                Object.extend(Validation.methods, nv);
            }
        }.bind(productAddToCartForm);
    //]]>
    </script>
    </div>

    <div class="product-collateral">
<?php foreach ($this->getChildGroup('detailed_info', 'getChildHtml') as $alias => $html):?>
        <div class="box-collateral <?php echo "box-{$alias}"?>">
            <?php if ($title = $this->getChildData($alias, 'title')):?>
            <h2><?php echo $this->escapeHtml($title); ?></h2>
            <?php endif;?>
            <?php echo $html; ?>
        </div>
<?php endforeach;?>
        <?php echo $this->getChildHtml('upsell_products') ?>
        <?php echo $this->getChildHtml('product_additional_data') ?>
    </div>
</div>

Below is the code of my product/view/media.phtml page: 以下是我的product / view / media.phtml页面的代码:

<?php
    $_product = $this->getProduct();
    $_helper = $this->helper('catalog/output');
?>
<?php if ($_product->getImage() != 'no_selection' && $_product->getImage()): ?>

    <?php if (count($this->getGalleryImages()) > 0): ?>
<div class="more-views">
    <ul>
    <?php foreach ($this->getGalleryImages() as $_image): ?>
        <li>
            <a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>" title="<?php echo $_product->getName();?>" onClick="$('image').src = this.href; return false;"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>" width="56" height="56" alt="<?php echo $this->escapeHtml($_image->getLabel()) ?>" /></a>
        </li>
    <?php endforeach; ?>
    </ul>
</div>
<?php endif; ?><div class="product-image product-image-zoom">
    <?php
        $_img = '<img id="image" src="'.$this->helper('catalog/image')->init($_product, 'image').'" alt="'.$this->escapeHtml($this->getImageLabel()).'" title="'.$this->escapeHtml($this->getImageLabel()).'" />';
        echo $_helper->productAttribute($_product, $_img, 'image');
    ?>
</div>
<script type="text/javascript">
//<![CDATA[
    Event.observe(window, 'load', function() {
        product_zoom = new Product.Zoom('image', 'track', 'handle', 'zoom_in', 'zoom_out', 'track_hint');
    });
//]]>
</script>
<?php else: ?>
    <?php if (count($this->getGalleryImages()) > 0): ?>
<div class="more-views">
    <ul>
    <?php foreach ($this->getGalleryImages() as $_image): ?>
        <li>
            <a href="#" onclick="popWin('<?php echo $this->getGalleryUrl($_image) ?>', 'gallery', 'width=300,height=300,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;" title="<?php echo $this->escapeHtml($_image->getLabel()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>" width="56" height="56" alt="<?php echo $this->escapeHtml($_image->getLabel()) ?>" /></a>
        </li>
    <?php endforeach; ?>
    </ul>
</div>
<?php endif; ?>
<div class="product-image">
    <?php
        $_img = '<img src="'.$this->helper('catalog/image')->init($_product, 'image')->resize(265).'" alt="'.$this->escapeHtml($this->getImageLabel()).'" title="'.$this->escapeHtml($this->getImageLabel()).'" />';
        echo $_helper->productAttribute($_product, $_img, 'image');
    ?>
</div>
<?php endif; ?>

Below is where my catalog.xml loads in media.phtml: 以下是我的catalog.xml在media.phtml中加载的位置:

<block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/media.phtml"/>

Step 1 : Set block and html hints on via admin. 第1步:通过admin设置阻止和html提示。

Step 2 : Clear cookies. 第2步:清除Cookie。

Step 3 : Refresh page and you will find block name and .phtml associated with that block. 步骤3:刷新页面,您将找到块名称和与该块关联的.phtml。

This will lead you to debug .phtml and block code that should have rendered images as expected. 这将导致您调试.phtml并阻止应该按预期方式呈现图像的代码。

Now in case this does not solve provide what block and .phtml were called and paste those two files. 现在,如果无法解决问题,请提供被调用的块和.phtml并粘贴这两个文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM