1

I have installed a custom extension that I have purchased from magento extensions. The module displays above the add to cart button on the product page, inside the column on the right hand side. I would like to move the new extension underneath the image and cart options, out of the right hand side. I am a beginner magento developer, I can not figure out how to move this extensions position on the page. I have created custom blocks before and positioned those in different places but I cant seem to find how the extension asks to be positioned.

I am using magento 1.9

Please can somebody point me in the right direction for which file will hold the call for the page position

== == == == UPDATE == == == ==

Ok within app/code/local/BS/Carpet/etc/config.xml I have the following:

<?xml version="1.0"?>

1.0.5 standard BS_Carpet carpet

    <translate>
        <modules>
            <BS_Carpet>
                <files>
                    <default>BS_Carpet.csv</default>
                </files>
            </BS_Carpet>
        </modules>
    </translate>
    <events>
        <core_block_abstract_to_html_before>
            <observers>
                <carpetpricetemplate>
                    <type>model</type>
                    <class>carpet/observer</class>
                    <method>changeTemplate</method>
                </carpetpricetemplate>
            </observers>
        </core_block_abstract_to_html_before>
        <sales_convert_quote_item_to_order_item>
            <observers>
                <carpetcustomoptions>
                    <type>model</type>
                    <class>carpet/observer</class>
                    <method>salesConvertQuoteItemToOrderItem</method>
                </carpetcustomoptions>
            </observers>
        </sales_convert_quote_item_to_order_item>

        <sales_quote_item_set_product>
            <observers>
                <carpetsetprice>
                    <class>carpet/observer</class>
                    <method>quoteItemSetProduct</method>
                </carpetsetprice>
            </observers>
        </sales_quote_item_set_product>
    </events>
</frontend>
<admin>
    <routers>
        <carpet>
            <use>admin</use>
            <args>
                <module>BS_Carpet</module>
                <frontName>carpet</frontName>
            </args>
        </carpet>
    </routers>
</admin>
<adminhtml>     
    <acl>
        <resources>
            <all>
                <title>Allow Everything</title>
            </all>
            <admin>
                <children>
                    <BS_Carpet>
                        <title>Carpet Module</title>
                        <sort_order>10</sort_order>
                    </BS_Carpet>
                </children>
            </admin>
        </resources>
    </acl>
    <layout>
        <updates>
            <carpet>
                <file>carpet.xml</file>
            </carpet>
        </updates>
    </layout>
</adminhtml>   
<global>
    <models>
        <carpet>
            <class>BS_Carpet_Model</class>  
            <resourceModel>carpet_mysql4</resourceModel>             
        </carpet>  
        <carpet_mysql4>
            <class>BS_Carpet_Model_Mysql4</class>
        </carpet_mysql4>   
    </models>
    <resources>
        <carpet_setup>
            <setup>
                <module>BS_Carpet</module>
                <class>BS_Carpet_Model_Resource_Eav_Mysql4_Setup</class>
            </setup>
            <connection>
                <use>core_setup</use>
            </connection>
        </carpet_setup>
        <carpet_write>
            <connection>
                <use>core_write</use>
            </connection>
        </carpet_write>
        <carpet_read>
            <connection>
                <use>core_read</use>
            </connection>
        </carpet_read>
    </resources>

    <blocks>
        <carpet>
            <class>BS_Carpet_Block</class>
        </carpet>
    </blocks>
    <helpers>
        <carpet>
            <class>BS_Carpet_Helper</class>
        </carpet>
    </helpers>
</global>
    <default>
    <bs_carpet>
        <general><active>1</active></general>
        <general><width>Width</width></general> 
        <general><length>Length</length></general>                      
    </bs_carpet>
</default>

== == == == UPDATE 2 == == == ==

<?php

class BS_Carpet_Model_Observer {

/**

 * Add additional options to order item product options (this is missing in the core)

 *

 * @param Varien_Event_Observer $observer

 */

public function salesConvertQuoteItemToOrderItem(Varien_Event_Observer $observer)

{

    $quoteItem = $observer->getItem();

    if ($additionalOptions = $quoteItem->getOptionByCode('additional_options')) {

        $orderItem = $observer->getOrderItem();

        $options = $orderItem->getProductOptions();

        $options['additional_options'] = unserialize($additionalOptions->getValue());

        $orderItem->setProductOptions($options);

    }

}



public function changeTemplate(Varien_Event_Observer $observer)

{

    $_block = $observer->getBlock();

    /*get Block type*/

    $_type = $_block->getType();

    $template = $_block->getTemplate();



    //print_r($_type);

    $currentProduct = Mage::registry('current_product');

    if($currentProduct){

        if($_type == 'page/html_head'){



            if($currentProduct->getId() && Mage::getStoreConfigFlag('bs_carpet/general/active')){

                $isCarpet = $currentProduct->getIsCarpetProduct();

                if($isCarpet){

                    $_block->addItem('skin_css','css/carpet/style.css');

                }



            }

        }









        if($_type == 'catalog/product_view' && strpos($template,'options/wrapper.')){

            if($currentProduct->getId() && Mage::getStoreConfigFlag('bs_carpet/general/active')){

                $isCarpet = $currentProduct->getIsCarpetProduct();

                if($isCarpet){



                    $_child = clone $_block;

                    $_child->setType('catalog/product_view');

                    $_child->setTemplate('carpet/calc.phtml');



                    $_block->append($_child);

                }



            }

        }



        if($_type == 'catalog/product_view' && strpos($template,'wrapper/bottom')){

            if($currentProduct->getId() && Mage::getStoreConfigFlag('bs_carpet/general/active')){

                $isCarpet = $currentProduct->getIsCarpetProduct();

                if($isCarpet){



                    $_child = clone $_block;

                    $_child->setType('catalog/product_view');

                    $_child->setTemplate('carpet/init.phtml');



                    $_block->append($_child);



                }



            }

        }





    }







}





public function quoteItemSetProduct($observer) {



    $quoteItem = $observer->getEvent()->getQuoteItem();

    if (!$quoteItem || !$quoteItem->getProductId() || !$quoteItem->getQuote() || $quoteItem->getQuote()->getIsSuperMode()) return $this;



    $product = $observer->getEvent()->getProduct();



    $productId = $quoteItem->getProduct()->getId();

    $_product = Mage::getModel('catalog/product')->load($productId);



    $widthTitle = strtolower(Mage::getStoreConfig('bs_carpet/general/width'));

    if($widthTitle == '') {$widthTitle = 'width';}

    $lengthTitle = strtolower(Mage::getStoreConfig('bs_carpet/general/length'));

    if($lengthTitle == '') {$lengthTitle = 'length';}





    $finalPrice = $product->getFinalPrice();

    $basePrice = $finalPrice;



    $multi = 1;

    $width = 0;

    $length = 0;

    $optionPrice = 0;





    if($_product->getIsCarpetProduct()==1){

        // prepare post data

        $post = $quoteItem->getProduct()->getCustomOption('info_buyRequest')->getValue();

        if ($post) $post = unserialize ($post); else $post = array();

        if (isset($post['options'])) $options = $post['options']; else $options = false;







        if ($options) {



            $optionsWeight = 0;

            foreach ($options as $optionId => $option) {





                $productOption = Mage::getModel('catalog/product_option')->load($optionId);



                $_option = $product->getOptionById($optionId);

                //Mage::log($_option->getTitle());

                $confItemOption = $product->getCustomOption('option_'.$_option->getId());

                $value = $confItemOption->getValue();

                //$optionValueModel = Mage::getModel('catalog/product_option_value')->load($value);



                $group = $_option->groupFactory($_option->getType())

                    ->setOption($_option)

                    ->setConfigurationItemOption($confItemOption);



                if(strtolower($_option->getTitle())==$lengthTitle){



                    if($_option->getType() == 'drop_down'){

                        $length = (float)$group->getFormattedOptionValue($confItemOption->getValue());

                    }else {

                        $length = (float)$confItemOption->getValue();

                    }



                }else if(strtolower($_option->getTitle())==$widthTitle){



                    if($_option->getType() == 'drop_down'){

                        $width = (float)$group->getFormattedOptionValue($confItemOption->getValue());

                    }else {

                        $width = (float)$confItemOption->getValue();

                    }

                }



                $optionPrice += $group->getOptionPrice($confItemOption->getValue(), $basePrice);







            }



            $dimenion = $width * $length;



            $tierPrice = $this->getTierPrice($dimenion, $product);



            if(is_array($tierPrice)){

                $tierPrice = $finalPrice;

            }



            if($tierPrice > $finalPrice){

                $tierPrice = $finalPrice;

            }



            $totalPrice = $dimenion * ($tierPrice + $optionPrice);



            $quoteItem->setCustomPrice($totalPrice);

            $quoteItem->setOriginalCustomPrice($totalPrice);





        }

    }





    return $this;

}



public function getTierPrice($qty = null, $product)

{

    $allGroups = Mage_Customer_Model_Group::CUST_GROUP_ALL;

    $prices = $product->getData('tier_price');



    if (is_null($prices)) {

        $attribute = $product->getResource()->getAttribute('tier_price');

        if ($attribute) {

            $attribute->getBackend()->afterLoad($product);

            $prices = $product->getData('tier_price');

        }

    }



    if (is_null($prices) || !is_array($prices)) {

        if (!is_null($qty)) {

            return $product->getPrice();

        }

        return array(array(

            'price'         => $product->getPrice(),

            'website_price' => $product->getPrice(),

            'price_qty'     => 1,

            'cust_group'    => $allGroups,

        ));

    }



    $custGroup = $this->_getCustomerGroupId($product);

    if ($qty) {

        $prevQty = 1;

        $prevPrice = $product->getPrice();

        $prevGroup = $allGroups;



        foreach ($prices as $price) {

            if ($price['cust_group']!=$custGroup && $price['cust_group']!=$allGroups) {

                // tier not for current customer group nor is for all groups

                continue;

            }

            if ($qty < $price['price_qty']) {

                // tier is higher than product qty

                continue;

            }

            if ($price['price_qty'] < $prevQty) {

                // higher tier qty already found

                continue;

            }

            if ($price['price_qty'] == $prevQty && $prevGroup != $allGroups && $price['cust_group'] == $allGroups) {

                // found tier qty is same as current tier qty but current tier group is ALL_GROUPS

                continue;

            }

            if ($price['website_price'] < $prevPrice) {

                $prevPrice  = $price['website_price'];

                $prevQty    = $price['price_qty'];

                $prevGroup  = $price['cust_group'];

            }

        }

        return $prevPrice;

    } else {

        $qtyCache = array();

        foreach ($prices as $i => $price) {

            if ($price['cust_group'] != $custGroup && $price['cust_group'] != $allGroups) {

                unset($prices[$i]);

            } else if (isset($qtyCache[$price['price_qty']])) {

                $j = $qtyCache[$price['price_qty']];

                if ($prices[$j]['website_price'] > $price['website_price']) {

                    unset($prices[$j]);

                    $qtyCache[$price['price_qty']] = $i;

                } else {

                    unset($prices[$i]);

                }

            } else {

                $qtyCache[$price['price_qty']] = $i;

            }

        }

    }



    return ($prices) ? $prices : array();

}



protected function _getCustomerGroupId($product)

{

    if ($product->getCustomerGroupId()) {

        return $product->getCustomerGroupId();

    }

    return Mage::getSingleton('customer/session')->getCustomerGroupId();

}

}

2 Answers 2

1

Usualy, well built modules can add it's blocks in next way:

Module have custom layout (xml) file, which mentioned in module/etc/config.xml and can look like

<layout>
    <updates>
        <neklo_giftcard>
            <file>neklo/giftcard.xml</file>
        </neklo_giftcard>
    </updates>
</layout>

look for it in section of config.

In the layout file of module you can have construction like:

<reference name="PARENT_BLOCK_NAME">
     <block type="your_module_name/custom_module_block" name="CUSTOM_BLOCK_NAME" template="custom_module_template.phtml" />
</reference>

Which means that module is adding it's block into Default Magento parent block.

In your case it can look like

<reference name=" name="product.info.addtocart">

or

<reference name="addtocart">

and you have to change it to

<reference name="product.info">

and after that, you'll need to place your block in catalog/product/view.phtml file, by calling

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

in the place you will choose.

But other ways of adding custom blocks are also possible and they can be very different. So if you'll provide at least config.xml of your module - we can try to find exact answer

==== UPDATE ====

Ok, so you will need to open file

app/code/local/BS/Carpet/Model/Observer.php

and find

public function changeTemplate()

Inside that fuction you will see one or several PHTML files mentioned, which replace default magento templates. But changing this custom templates you should be able to move your block in correct position. But, be attentive - if these custom blocks contain form elements, so they probably can not be moved out of Add To Cart form.

8
  • thanks for the detailed reply, I will have a look into your points. If I still cant find it I will start adding information from the files for some more help. Thank you very much
    – ADRIAN
    Jun 6, 2016 at 9:11
  • I have updated the original post and added the info from the config.xml, any help would be greatly appreciated
    – ADRIAN
    Jun 6, 2016 at 9:24
  • Answer is also updated
    – Neklo.com
    Jun 6, 2016 at 9:36
  • Thanks again for the reply, so if I understand correctly, because the extension is part of the form (uses information of the product to calculate the floor size and the amount needed) then I am unable to move the position out of the area where the product information is held?
    – ADRIAN
    Jun 6, 2016 at 9:44
  • Probably so. The minimum changes you can made is to move block after Add To Cart button, but before </form> element. But visually it can be placed far away from product information and it's based on your theme and design.
    – Neklo.com
    Jun 6, 2016 at 9:58
0

I believe, the block you are trying to move is generated at

if($_type == 'catalog/product_view' && strpos($template,'options/wrapper.')){

            if($currentProduct->getId() && Mage::getStoreConfigFlag('bs_carpet/general/active')){

                $isCarpet = $currentProduct->getIsCarpetProduct();

                if($isCarpet){

                    $_child = clone $_block;

                    $_child->setType('catalog/product_view');

                    $_child->setTemplate('carpet/calc.phtml');

                    $_block->append($_child);
                }
            }
        }

But this place custom block inside catalog/product/view/options/wrapper.phtml and if you will replace

$_block->append($_child);

with

$_block->setChild('CUSTOM_BLOCK_NAME', $_child);

you should be able to call

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

in catalog/product/view/options/wrapper.phtml And it's hard to tell if calc.phtml template (custom block) can be moved out of options wrapper.

4
  • that has made the extension appear in the exact same place. When i try the php echo call in the view.phtml it does not appear
    – ADRIAN
    Jun 6, 2016 at 11:05
  • I need to call it in a different file but the place is still within the </form>
    – ADRIAN
    Jun 6, 2016 at 11:06
  • To move this block to view.phtml you have to change Observer line: "if($_type == 'catalog/product_view' && strpos($template,'options/wrapper.')){" TO "if($_type == 'catalog/product_view' && strpos($template,'catalog/product/view.phtml')){". But there are no guarantee that custom block will work as it should after all.
    – Neklo.com
    Jun 6, 2016 at 11:07
  • No, unfortunately that has not made it display either.
    – ADRIAN
    Jun 6, 2016 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.