Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Modulo de Envio
 
Jonathan Moratelli
Member
 
Total Posts:  35
Joined:  2008-10-30
 

Criei um modulo de envio por motoboy utilizando como exemplo este tutorial http://www.magentocommerce.com/wiki/how-to/create-shipping-method-module.

Tudo funcionou corretamente exceto pelo fato de que a opção “Motoboy” é exibida duas vezes.

Já revirei o código e naum achei o porque disto acontecer.

config.xml

<?xml version="1.0"?>
<config>
    <
modules>
        <
Ofsrj_Clientetv>
            <
version>0.1.1</version>
        </
Ofsrj_Clientetv>
    </
modules>
    <
frontend>
        <
routers>
            <
clientetv>
                <use>
standard</use>
                <
args>
                    <
module>Ofsrj_Clientetv</module>
                    <
frontName>clientetv</frontName>
                </
args>
            </
clientetv>
        </
routers>
        <
layout>
            <
updates>
                <
clientetv>
                    <
file>clientetv.xml</file>
                </
clientetv>
            </
updates>
        </
layout>
    </
frontend>
    <
admin>
        <
routers>
            <
clientetv>
                <use>
admin</use>
                <
args>
                    <
module>Ofsrj_Clientetv</module>
                    <
frontName>clientetv</frontName>
                </
args>
            </
clientetv>
            <
ofsrj_clientetv>
                <!-- 
should be set to "admin" when overloading admin stuff (?) -->
                <use>
standard</use>
                <
args>
                    <
module>Ofsrj_Clientetv</module>
                    <!-- 
This is used when "catching" the rewrite above -->
                    <
frontName>clientetv</frontName>
                </
args>
            </
ofsrj_clientetv>
        </
routers>
    </
admin>
    <
adminhtml>
        <
menu>
            <
clientetv module="clientetv">
                <
title>Clientetv</title>
                <
sort_order>71</sort_order>               
                <
children>
                    <
items module="clientetv">
                        <
title>Manage Items</title>
                        <
sort_order>0</sort_order>
                        <
action>clientetv/adminhtml_clientetv</action>
                    </
items>
                </
children>
            </
clientetv>
        </
menu>
        <
acl>
            <
resources>
                <
all>
                    <
title>Allow Everything</title>
                </
all>
                <
admin>
                    <
children>
                        <
Ofsrj_Clientetv>
                            <
title>Clientetv Module</title>
                            <
sort_order>10</sort_order>
                        </
Ofsrj_Clientetv>
                    </
children>
                </
admin>
            </
resources>
        </
acl>
        <
layout>
            <
updates>
                <
clientetv>
                    <
file>clientetv.xml</file>
                </
clientetv>
            </
updates>
        </
layout>
    </
adminhtml>   
    <global>
        <!-- 
This rewrite rule could be added to the database instead -->
        <
rewrite>
            <!-- 
This is an identifier for your rewrite that should be unique -->
            <!-- 
THIS IS THE CLASSNAME IN YOUR OWN CONTROLLER -->
            <
ofsrj_clientetv_checkout_onepage_saveshipping>
                <
from><![CDATA[#^/checkout/onepage/saveShipping/$#]]></from>
                
<!--
                    - 
mymodule matches the router frontname below
                    
checkout_cart matches the path to your controller
                   
                    Considering the router below
"/mymodule/checkout_cart/" will be
                    
"translated" to "/MyNameSpace/MyModule/controllers/Checkout/CartController.php" (?)
                -->
                <
to>/clientetv/checkout_onepage/saveShipping/</to>
            </
ofsrj_clientetv_checkout_onepage_saveshipping>
            <
ofsrj_clientetv_checkout_onepage_savebilling>
                <
from><![CDATA[#^/checkout/onepage/saveBilling/$#]]></from>
                
<to>/clientetv/checkout_onepage/saveBilling/</to>
            </
ofsrj_clientetv_checkout_onepage_savebilling>
        </
rewrite>
        <
models>
            <
clientetv>
                <class>
Ofsrj_Clientetv_Model</class>
                <
resourceModel>clientetv_mysql4</resourceModel>
            </
clientetv>
            <
clientetv_mysql4>
                <class>
Ofsrj_Clientetv_Model_Mysql4</class>
                <
entities>
                    <
clientetv>
                        <
table>clientetv</table>
                    </
clientetv>
                    <
endereco>
                        <
table>clientetv_endereco</table>
                    </
endereco>
                    <
telefone>
                        <
table>clientetv_telefone</table>
                    </
telefone>                    
                </
entities>
            </
clientetv_mysql4>
            <
checkout>
                <
rewrite>
                    <
type_onepage>Ofsrj_Clientetv_Model_Onepage</type_onepage>
                </
rewrite>
            </
checkout>
        </
models>
        <
resources>
            <
clientetv_setup>
                <
setup>
                    <
module>Ofsrj_Clientetv</module>
                </
setup>
                <
connection>
                    <use>
core_setup</use>
                </
connection>
            </
clientetv_setup>
            <
clientetv_write>
                <
connection>
                    <use>
core_write</use>
                </
connection>
            </
clientetv_write>
            <
clientetv_read>
                <
connection>
                    <use>
core_read</use>
                </
connection>
            </
clientetv_read>
        </
resources>
        <
blocks>
            <
clientetv>
                <class>
Ofsrj_Clientetv_Block</class>
            </
clientetv>
            <
checkout>
                <
rewrite>
                    <
onepage_shipping>Ofsrj_Clientetv_Block_Onepage_Shipping</onepage_shipping>
                    <
onepage_billing>Ofsrj_Clientetv_Block_Onepage_Billing</onepage_billing>
                </
rewrite>
            </
checkout>
        </
blocks>
        <
helpers>
            <
clientetv>
                <class>
Ofsrj_Clientetv_Helper</class>
            </
clientetv>
        </
helpers>
    </global>
    <default>
<!-- 
'payment' configuration section (tab) -->
       <
payment>
<!-- 
'newmodule' configuration group (fieldset) -->
           <
pgtotv>
<!-- 
by default this payment method is inactive -->
               <
active>0</active>
<!-- 
model to handle logic for this payment method -->
               <
model>clientetv/payment_pgtotv</model>
<!-- 
order status for new orders paid by this payment method -->
               <
order_status>1</order_status>
<!-- default 
title for payment checkout page and order view page -->
               <
title>Pagamento TeleVendas</title>
<!--                <
payment_action>authorize</payment_action> -->
               <
allowspecific>0</allowspecific>
           </
pgtotv>
        </
payment>
        <
carriers>
            <
motoboy>
                    <
active>1</active>
                    <
sallowspecific>0</sallowspecific>
                    <
model>clientetv/carrier_motoboy</model>
                    <
name>Motoboy</name>
                    <
title>Motoboy</title>
                    <
specificerrmsg>
                        
This shipping method is currently unavailable.
                        If 
you would like to ship using this shipping
                        method
please contact us.
                    </
specificerrmsg>
                    <
handling_type>F</handling_type>
            </
motoboy>
        </
carriers>
    </default>
</
config>

system.xml

<?xml version="1.0"?>
      
<config>
         <
sections>
          <
carriers>
              <
groups>
                  <
motoboy translate="label" module="shipping">
                      <
label>Motoboy</label>
                      <
frontend_type>text</frontend_type>
                      <
sort_order>13</sort_order>
                      <
show_in_default>1</show_in_default>
                      <
show_in_website>1</show_in_website>
                      <
show_in_store>1</show_in_store>
                         <
fields>
                            <
account translate="label">
                                  <
label>Account number</label>
                                  <
frontend_type>text</frontend_type>
                                  <
sort_order>7</sort_order>
                                  <
show_in_default>1</show_in_default>
                                  <
show_in_website>1</show_in_website>
                                  <
show_in_store>1</show_in_store>
                              </
account>
                              <
active translate="label">
                                  <
label>Enabled</label>
                                  <
frontend_type>select</frontend_type>
                                  <
source_model>adminhtml/system_config_source_yesno</source_model>
                                  <
sort_order>1</sort_order>
                                  <
show_in_default>1</show_in_default>
                                  <
show_in_website>1</show_in_website>
                                  <
show_in_store>1</show_in_store>
                              </
active>
                              <
contentdesc translate="label">
                                  <
label>Package Description</label>
                                  <
frontend_type>text</frontend_type>
                                  <
sort_order>12</sort_order>
                                  <
show_in_default>1</show_in_default>
                                  <
show_in_website>1</show_in_website>
                                  <
show_in_store>1</show_in_store>
                              </
contentdesc>
                              <!--
                              If 
the free_shipping_enable flag enablethe system will check free_shipping_subtotal to give free shipping
                              otherwise will 
use shopping cart price rule behaviour
                              
-->
                              <
free_shipping_enable translate="label">
                                  <
label>Free shipping with minimum order amount</label>
                                  <
frontend_type>select</frontend_type>
                                  <
source_model>adminhtml/system_config_source_enabledisable</source_model>
                                  <
sort_order>21</sort_order>
                                  <
show_in_default>1</show_in_default>
                                  <
show_in_website>1</show_in_website>
                                  <
show_in_store>1</show_in_store>
                              </
free_shipping_enable>
                              <
free_shipping_subtotal translate="label">
                                  <
label>Minimum order amount for free shipping</label>
                                  <
frontend_type>text</frontend_type>
                                  <
sort_order>22</sort_order>
                                  <
show_in_default>1</show_in_default>
                                  <
show_in_website>1</show_in_website>
                                  <
show_in_store>1</show_in_store>
                              </
free_shipping_subtotal>
                              <
dutiable translate="label">
                                  <
label>Shipment Dutiable</label>
                                  <
frontend_type>select</frontend_type>
                                  <
source_model>adminhtml/system_config_source_yesno</source_model>
                                  <
sort_order>13</sort_order>
                                  <
show_in_default>1</show_in_default>
                                  <
show_in_website>1</show_in_website>
                                  <
show_in_store>1</show_in_store>
                              </
dutiable>
                              <
gateway_url translate="label">
                                  <
label>Gateway URL</label>
                                  <
frontend_type>text</frontend_type>
                                  <
sort_order>2</sort_order>
                                  <
show_in_default>1</show_in_default>
                                  <
show_in_website>1</show_in_website>
                                  <
show_in_store>1</show_in_store>
                              </
gateway_url>
                              <
handling_type translate="label">
                                  <
label>Calculate Handling Fee</label>
                                  <
frontend_type>select</frontend_type>
                                  <
source_model>shipping/source_handlingType</source_model>
                                  <
sort_order>10</sort_order>
                                  <
show_in_default>1</show_in_default>
                                  <
show_in_website>1</show_in_website>
                                  <
show_in_store>0</show_in_store>
                              </
handling_type>
                              <
handling_action translate="label">
                                  <
label>Handling Applied</label>
                                  <
frontend_type>select</frontend_type>
                                  <
source_model>shipping/source_handlingAction</source_model>
                                  <
sort_order>11</sort_order>
                                  <
show_in_default>1</show_in_default>
                                  <
show_in_website>1</show_in_website>
                                  <
show_in_store>0</show_in_store>
                              </
handling_action>
                              <
handling_fee translate="label">
                                  <
label>Handling fee</label>
                                  <
frontend_type>text</frontend_type>
                                  <
sort_order>12</sort_order>
                                  <
show_in_default>1</show_in_default>
                                  <
show_in_website>1</show_in_website>
                                  <
show_in_store>1</show_in_store>
                              </
handling_fee>
                              <
max_package_weight translate="label">
                                  <
label>Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)</label>
                                  <
frontend_type>text</frontend_type>
                                  <
sort_order>13</sort_order>
                                  <
show_in_default>1</show_in_default>
                                  <
show_in_website>1</show_in_website>
                                  <
show_in_store>1</show_in_store>
                              </
max_package_weight>
                              <
id translate="label">
                                  <
label>Access ID</label>
                                  <
frontend_type>text</frontend_type>
                                  <
backend_model>adminhtml/system_config_backend_encrypted</backend_model>
                                  <
sort_order>5</sort_order>
                                  <
show_in_default>1</show_in_default>
                                  <
show_in_website>1</show_in_website>
                                  <
show_in_store>1</show_in_store>
                              </
id>
                              <
password translate="label">
                                  <
label>Password</label>
                                  <
frontend_type>text</frontend_type>
                                  <
backend_model>adminhtml/system_config_backend_encrypted</backend_model>
                                  <
sort_order>6</sort_order>
                                  <
show_in_default>1</show_in_default>
                                  <
show_in_website>1</show_in_website>
                                  <
show_in_store>1</show_in_store>
                              </
password>
                              <
shipping_intlkey translate="label">
                                  <
label>Shipping key (International)</label>
                                  <
frontend_type>text</frontend_type>
                                  <
backend_model>adminhtml/system_config_backend_encrypted</backend_model>
                                  <
sort_order>8</sort_order>
                                  <
show_in_default>1</show_in_default>
                                  <
show_in_website>1</show_in_website>
                                  <
show_in_store>1</show_in_store>
                              </
shipping_intlkey>
                              <
shipping_key translate="label">
                                  <
label>Shipping key</label>
                                  <
frontend_type>text</frontend_type>
                                  <
backend_model>adminhtml/system_config_backend_encrypted</backend_model>
                                  <
sort_order>8</sort_order>
                                  <
show_in_default>1</show_in_default>
                                  <
show_in_website>1</show_in_website>
                                  <
show_in_store>1</show_in_store>
                              </
shipping_key>
                              <
sort_order translate="label">
                                  <
label>Sort order</label>
                                  <
frontend_type>text</frontend_type>
                                  <
sort_order>100</sort_order>
                                  <
show_in_default>1</show_in_default>
                                  <
show_in_website>1</show_in_website>
                                  <
show_in_store>1</show_in_store>
                              </
sort_order>
                              <
title translate="label">
                                  <
label>Title</label>
                                  <
frontend_type>text</frontend_type>
                                  <
sort_order>2</sort_order>
                                  <
show_in_default>1</show_in_default>
                                  <
show_in_website>1</show_in_website>
                                  <
show_in_store>1</show_in_store>
                              </
title>
                              <
sallowspecific translate="label">
                                  <
label>Ship to applicable countries</label>
                                  <
frontend_type>select</frontend_type>
                                  <
sort_order>90</sort_order>
                                  <
frontend_class>shipping-applicable-country</frontend_class>
                                  <
source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
                                  <
show_in_default>1</show_in_default>
                                  <
show_in_website>1</show_in_website>
                                  <
show_in_store>1</show_in_store>
                              </
sallowspecific>
                              <
specificcountry translate="label">
                                  <
label>Ship to Specific countries</label>
                                  <
frontend_type>multiselect</frontend_type>
                                  <
sort_order>91</sort_order>
                                  <
source_model>adminhtml/system_config_source_country</source_model>
                                  <
show_in_default>1</show_in_default>
                                  <
show_in_website>1</show_in_website>
                                  <
show_in_store>1</show_in_store>
                              </
specificcountry>
                              <
showmethod translate="label">
                                  <
label>Show method if not applicable</label>
                                  <
frontend_type>select</frontend_type>
                                  <
sort_order>92</sort_order>
                                  <
source_model>adminhtml/system_config_source_yesno</source_model>
                                  <
show_in_default>1</show_in_default>
                                  <
show_in_website>1</show_in_website>
                                  <
show_in_store>1</show_in_store>
                              </
showmethod>
                              <
specificerrmsg translate="label">
                                  <
label>Displayed Error Message</label>
                                  <
frontend_type>textarea</frontend_type>
                                  <
sort_order>80</sort_order>
                                  <
show_in_default>1</show_in_default>
                                  <
show_in_website>1</show_in_website>
                                  <
show_in_store>1</show_in_store>
                              </
specificerrmsg>                 
                          </
fields>
                      </
motoboy>
                  </
groups>
              </
carriers>
          </
sections>
      </
config>
[c/ode]

Model
/Carrier/Motoboy.php
[code]<?php

/**
* Our test shipping method module adapter
*/
class Ofsrj_Clientetv_Model_Carrier_Motoboy extends Mage_Shipping_Model_Carrier_Abstract
{
  
/**
   * unique internal shipping method identifier
   *
   * @var string [a-z0-9_]
   */
  
protected $_code 'motoboy';
 
    
/**
     * Collect rates for this shipping method based on information in $request
     *
     * @param Mage_Shipping_Model_Rate_Request $data
     * @return Mage_Shipping_Model_Rate_Result
     */
  
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
  
{
    
// skip if not enabled
    
if (!Mage::getStoreConfig('carriers/'.$this->_code.'/active')) {
        
return false;
    
}
 
    
/**
     * here we are retrieving shipping rates from external service
     * or using internal logic to calculate the rate from $request
     * you can see an example in Mage_Usa_Model_Shipping_Carrier_Ups::setRequest()
     */
 
    // get necessary configuration values
    
$handling Mage::getStoreConfig('carriers/'.$this->_code.'/handling');
 
    
// this object will be returned as result of this method
    // containing all the shipping rates of this method
    
$result Mage::getModel('shipping/rate_result');
 
    
// $response is an array that we have
//    foreach ($response as $rMethod) {
      // create new instance of method rate
      
$method Mage::getModel('shipping/rate_result_method');
 
      
// record carrier information
      
$method->setCarrier($this->_code);
      
$method->setCarrierTitle(Mage::getStoreConfig('carriers/'.$this->_code.'/title'));
 
      
// record method information
      
$method->setMethod('Motoboy');
      
$method->setMethodTitle('Motoboy');
 
      
// rate cost is optional property to record how much it costs to vendor to ship
      //$method->setCost(10.00);
 
      // in our example handling is fixed amount that is added to cost
      // to receive price the customer will pay for shipping method.
      // it could be as well percentage:
      /// $method->setPrice($rMethod['amount']*$handling/100);
      
$method->setPrice(0);
 
      
// add this rate to the result
      
$result->append($method);
//    }
 
    
return $result;
  
}
}

Alguém já passou por isso ou pode me ajudar???

Image Attachments
shipping.JPG
 
Magento Community Magento Community
Magento Community
Magento Community
 
Carlos Teixeira
Sr. Member
 
Total Posts:  95
Joined:  2009-01-26
Brasil
 

Ja passei por isso !!!

Provavelmente quando vc estava desenvolvendo vc deixou de alterar “carrier_name” (como é explicado no tutorial ) dentro system.xml, depois simplesmente alterou para “motoboy” isso cria duas instancias do modulo no sistema.

Execute a seguinte query no seu banco e veja não ha uma entrada duplicada do seu modulo, se tiver registros referente ao mesmo, remova o duplicado.

SELECT *
FROM core_config_data
WHERE path LIKE ‘carrier%’

Provavelmente no resultado algo que comece com “carriers/carrier_name/...”

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jonathan Moratelli
Member
 
Total Posts:  35
Joined:  2008-10-30
 

Muito obrigado Carlos Teixeira, nem sei como te agradecer.

Perguntei no forum em ingles e ninguém me respondeu.

Foi exatamente isso que aconteceu, primeiro utilizei carrier_name de depois mudei.

Agora está funcionando corretamente.

Valew!!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
APEofGOD
Sr. Member
 
Avatar
Total Posts:  100
Joined:  2008-05-28
 

Disponibiliza o pacote pronto pro pessoal, edita o nome do tópico para “Entrega via Motoboy” ou outra coisa, o título desse tópico não tá muito sugestivo. =D

 
Magento Community Magento Community
Magento Community
Magento Community
 
ivobarbosa
Jr. Member
 
Total Posts:  11
Joined:  2010-04-22
 

Amigos tentei fazer um modulo, pelo link do post1, o modulo aparece correctamente no admin mas não aparece no frontend, alguem que me posso ajudar?
Obrigado.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top