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

How to get this extension to work for magento 1.6.1 (customer-group-switcher)
 
absolutex
Member
 
Total Posts:  31
Joined:  2011-05-17
 

I’m also trying to do this.  I found Vinai’s extension in Magento Connect (http://www.magentocommerce.com/magento-connect/vinai/extension/1666/customer-group-switcher) and have tried to install it in 1.6.0.0 but am getting an error:

Fatal errorAccess level to Netzarbeiter_GroupSwitcher_Block_Adminhtml_Groupswitcher_Rules_Grid::getRowUrl() must be public (as in class Mage_Adminhtml_Block_Widget_Gridin /home/shsofmo/public_html/dev/store/app/code/community/Netzarbeiter/GroupSwitcher/Block/Adminhtml/Groupswitcher/Rules/Grid.php on line 32

and i changed

app\code\community\Netzarbeiter\GroupSwitcher\Block\Adminhtml\Groupswitcher\Rules

edit Grid.php to change line 145 from

protected function getRowUrl($row)

to

public function getRowUrl($row)

Error has gone but i getting “BLANK PAGE” when “submit shipment”

For download

http://freegento.com/magento-extensions/Netzarbeiter_GroupSwitcher-0.1.8beta_ready2paste.tgz

http://www.magentocommerce.com/magento-connect/vinai/extension/1666/customer-group-switcher

http://freegento.com/ddl-magento-extension.php
community/Netzarbeiter_GroupSwitcher

If anyone has any ideas or suggestions (to get this extension working or any other alternative for adding customers to groups based on purchase), I’d love to hear them.

Thanks you.

 
Magento Community Magento Community
Magento Community
Magento Community
 
elvar
Member
 
Total Posts:  59
Joined:  2009-01-30
 

Hi…

Today I found this extensions (I cant believe I never saw it before and I am trying to make a membership module).

I downloaded it and changed the public statement in grid.php. Renamed the community folder to local folder and also in xml of the module (dont know if this is needed but I like to have it clean - so local means to me that I am doing my changes there).

Uploaded all to server, had an error about updating mysql table (already existed) but on the next load everything is doing ok. I even create the order and shipment without a problem.

But after creating an invoice I get an errors. I need to say this module is really old code and there need to be lots of changes. However, I succesfuly made a changes to be able to change customer group after certain number of orders.

- in admin - customer - customer group - add rule to change group after 3 orders - I check order state as Complete only
- in Model/Rule/Type/NumOrders.php change the function code:

protected function _getCustomerOrderCount(Mage_Customer_Model_Customer $customerMage_Sales_Model_Order $order)
    
{
        
if (isset($this->_customerId) && $this->_customerId == $customer->getId())
        
{
            
return $this->_orderCount;
        
}
        $orders 
Mage::getModel(\'sales/order\')->getCollection()
                ->
addFieldToFilter(\'status\'\'complete\')
                ->
addFieldToFilter(\'customer_id\'$customer->getId());
        
$this->_orderCount $orders->count();
        return 
$this->_orderCount;
    
}

and it worked. I had error in admin:

a:5:{i:0;s:160:\"Cannot send headers; headers already sent in /app/code/local/Netzarbeiter/GroupSwitcher/Model/Rule/Type/NumOrders.php, line 75\";i:1;s:1467:\"#0 lib/Zend/Controller/Response/Abstract.php(148):
but customer group is changed!!!

There is a quite a lot of work to change all of this but I think it is doable for anything you need. Lets do it here together smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
absolutex
Member
 
Total Posts:  31
Joined:  2011-05-17
 

Thanks for answer.

but my \"Rule Type\” is \"Total turnover of the customer\” , \"Single order total\”

in Model/Rule/Type/OrderTotal.php

class Netzarbeiter_GroupSwitcher_Model_Rule_Type_OrderTotal
    
extends Netzarbeiter_GroupSwitcher_Model_Rule_Type_Abstract
{
    
/**
     * Check if the order total is equal or larger then the rule value
     *
     * @param Mage_Customer_Model_Customer $customer
     * @param Mage_Sales_Model_Order $order
     * @return bool
     */
    
public function _match(Mage_Customer_Model_Customer $customerMage_Sales_Model_Order $order)
    
{
        
return $this->getRule()->getRuleValue() >= ($order->getGrandTotal() - $order->getShippingAmount());
    
}

in Model/Rule/Type/TurnoverTotal.php

class Netzarbeiter_GroupSwitcher_Model_Rule_Type_TurnoverTotal
    
extends Netzarbeiter_GroupSwitcher_Model_Rule_Type_TurnoverAbstract
{

    
/**
     * Check if the total turnover of all of the customers orders are equal or higher then rule value.
     *
     * @param Mage_Customer_Model_Customer $customer
     * @param Mage_Sales_Model_Order $order
     * @return bool
     */
    
public function _match(Mage_Customer_Model_Customer $customerMage_Sales_Model_Order $order)
    
{
        $turnover 
$this->_getCustomerTurnover($customer$order);

        return 
$turnover >= (double) $this->getRule()->getRuleValue();
    
}
}

How to get this code to work for magento 1.6.1.0

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
elvar
Member
 
Total Posts:  59
Joined:  2009-01-30
 

Well, I tried to make it with this:

protected function _getCustomerTurnover(Mage_Customer_Model_Customer $customerMage_Sales_Model_Order $order$days 0)
    
{
        
if (isset($this->_customerId) && $this->_customerId == $customer->getId())
        
{
            
return $this->_turnover;
        
}

        $orders 
Mage::getResourceModel('sales/sale_collection')
                ->
setOrderStateFilter(Mage_Sales_Model_Order::STATE_CANCELEDtrue)
                ->
setCustomerFilter($customer->getId())
                ->
load();
        
//echo $orders->getTotals();
        
$this->_turnover $orders->getTotals();

        return 
$this->_turnover;
    
}

and invoice and shipment is generated without errors. However, customer group was not changed. But you can investigate what to call (maybe getTotals is not what we want).

p.s. I did not used filtering of days since just wanted to get it running

 
Magento Community Magento Community
Magento Community
Magento Community
 
elvar
Member
 
Total Posts:  59
Joined:  2009-01-30
 

Hi again!

I tried once more. What now I have changed is just DELETED the

if ($this->getRule()->getOrderStatus())

section in the /GroupSwitcher/Model/Rule/Type/TurnoverAbstract.php

So basically, observer will trigger only after you have made order - shipment - invoice - and customer group will be changed if lifetime turnover (or in last x days) will be more then configured.

It works without checking the final order status.

I hope you is satisfied with it.

 
Magento Community Magento Community
Magento Community
Magento Community
 
absolutex
Member
 
Total Posts:  31
Joined:  2011-05-17
 

Wow. it\’s work.

So.. in Model/Rule/Type/NumOrders.php:

protected function _getCustomerOrderCount

Just only remove

function

if ($this->getRule()->getOrderStatus())

same as

protected function _getCustomerTurnover

in /GroupSwitcher/Model/Rule/Type/TurnoverAbstract.php

??

Thanks.!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
tmp2000
Jr. Member
 
Total Posts:  9
Joined:  2011-07-14
 

Got the problem too.
I find it will be fixed for turnover with

protected function _getCustomerTurnover(Mage_Customer_Model_Customer $customerMage_Sales_Model_Order $order$days 0)
    
{
        
if (isset($this->_customerId) && $this->_customerId == $customer->getId())
        
{
            
return $this->_turnover;
        
}

        $this
->_customerId $customer->getId();
        
$resource $order->getResource();
        
$adapter $resource->getReadConnection();
        
$bind = array('customer_id' => $customer->getId());
        
$select $adapter->select()
            ->
from(array('main_table' => $resource->getTable('sales/order')), 'SUM(grand_total) - SUM(shipping_amount)')
            ->
where('main_table.customer_id=:customer_id')
            ;
        if (
$days 0)
        
{
            $select
->where(sprintf('DATE_SUB(CURDATE(), INTERVAL %d DAY) <= DATE(main_table.created_at)'$days));
        
}
        
if ($this->getRule()->getOrderStatus())
        
{
            
/*$select
                ->joinInner( // eav sales order varchar table, current order status is saved there
                    array(
                        "_status_table" => "{$this->_getOrderStatusAttribute()->getBackend()->getTable()}",
                    ),
                    "_status_table.entity_id = main_table.entity_id AND _status_table.attribute_id = {$this->_getOrderStatusAttribute()->getId()} AND _status_table.value=:order_status",
                    ""
                )
                ;*/
            
$select->where('main_table.state=:order_status');
            
$bind['order_status'$this->getRule()->getOrderStatus();
        
}
        
//Mage::log(array('select' => (string) $select, 'bind' => $bind));
        
$this->_turnover $adapter->fetchOne($select$bind);


        return 
$this->_turnover;
    
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
rjaskelton1982
Jr. Member
 
Total Posts:  3
Joined:  2012-01-03
 

I like this extension, but I’m wondering if someone can help me out. I would like to create a new rule that would be something like Total Purchased Quantity equals or greater than 250. Does anyone know how to do this?

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