Pedido personalizado, factura y números de inicio de envío


Respuestas:


7

Si deseo continuar usando el tipo de incremento predeterminado de Magento y solo quiero cambiar el siguiente número de incremento, esto es lo que uso.

¡Asegúrese de usar solo números de incremento que sean más grandes que los que ya se usaron!

SET @next_increment='310000000';

SELECT @entity_types:=GROUP_CONCAT(`entity_type_id`) FROM `eav_entity_type`
    WHERE `entity_type_code` IN ('order', 'invoice', 'shipment');

SELECT @new_last_increment:=GREATEST((@next_increment -1), 
    (SELECT MAX(`increment_last_id`) FROM `eav_entity_store`
     WHERE FIND_IN_SET(`entity_type_id`, @entity_types)));

UPDATE `eav_entity_store` SET `increment_last_id`=@new_last_increment
    WHERE FIND_IN_SET(`entity_type_id`, @entity_types);

Este SQL debe tener cuidado de no establecer accidentalmente un ID de incremento que ya se haya utilizado.
Si next_incrementya se utilizó un incremento mayor , simplemente establece el último número de incremento para los tres tipos de entidades para que sean iguales.


2

No estoy seguro acerca de la palanca de seguridad, pero lo estoy haciendo modificando los valores en DB directamente:

    UPDATE `eav_entity_store` s
INNER JOIN `eav_entity_type` t ON t.`entity_type_id` = s.`entity_type_id`
       SET s.`increment_last_id` = 'your_increment_here'
     WHERE t.entity_type_code = "order";

Reemplace el código de tipo de entidad con "factura" o "envío" para hacer lo mismo para el resto.


2

Si desea utilizar rangos de números personalizados o formatos para ID de incremento en lugar de los incrementos predeterminados de Magento, también puede asignar un modelo de incremento personalizado.

Por ejemplo:

class My_Shop_Model_Entity_Increment_Erp
    extends Mage_Eav_Model_Entity_Increment_Abstract
{
    public function getNextId()
    {
        $last = $this->getLastId();
        $entity = $this->getEntityTypeId();
        $store = $this->getStoreId()
        $next = Mage::helper('my_shop/api')->getNextIncrementFromErp($last, $entity, $store);

        // If you want to apply pad char and length, otherwise simply return $next
        return $this->format($next);
    }
}

Luego, actualice el modelo de incremento para las entidades en un script de configuración:

$installer = Mage::getModel('eav/entity_setup',   'core_setup');
$installer->startSetup();
$installer->updateEntityType('order',    'increment_model', 'my_shop/entity_increment_erp');
$installer->updateEntityType('invoice',  'increment_model', 'my_shop/entity_increment_erp');
$installer->updateEntityType('shipment', 'increment_model', 'my_shop/entity_increment_erp');
$installer->endSetup();

¡Asegúrese de no devolver ID de incremento que ya se usaban anteriormente!


2

La mejor manera [más segura para magento] de cambiar el número de pedido es cambiar los números de pedido siguientes y no los anteriores. Esto se puede hacer con una simple consulta de base de datos. Estos son los que utilicé en mi sitio y funciona sin ningún problema desde hace casi un año.

Orden:

    UPDATE eav_entity_store
INNER JOIN eav_entity_type ON eav_entity_type.entity_type_id = eav_entity_store.entity_type_id
SET eav_entity_store.increment_last_id='XXXXXXXXXX'
WHERE eav_entity_type.entity_type_code='order';

Factura:

UPDATE eav_entity_store
INNER JOIN eav_entity_type ON eav_entity_type.entity_type_id = eav_entity_store.entity_type_id
SET eav_entity_store.increment_last_id='XXXXXXXXXX'
WHERE eav_entity_type.entity_type_code='invoice';

Envío:

UPDATE eav_entity_store
INNER JOIN eav_entity_type ON eav_entity_type.entity_type_id = eav_entity_store.entity_type_id
SET eav_entity_store.increment_last_id='XXXXXXXXXX'
WHERE eav_entity_type.entity_type_code='shipment';

Estas consultas cambiarán los siguientes ID de incremento para su tienda magento. NOTA: Reemplace X con la siguiente identificación que desee.

Acepta una respuesta si funciona.


1
Copiado desde aquí, supongo warpconduit.net/2012/04/18/…
user487772

Sí, y la solución funciona.
Tarun

0

ID de incremento de pedido y prefijo

Cambie su ID de incremento de pedido en todas las tiendas

UPDATE eav_entity_store
INNER JOIN eav_entity_type ON eav_entity_type.entity_type_id = eav_entity_store.entity_type_id
SET eav_entity_store.increment_last_id='XXXXXXXXXX'
WHERE eav_entity_type.entity_type_code='order';

UPDATE eav_entity_store
INNER JOIN eav_entity_type ON eav_entity_type.entity_type_id = eav_entity_store.entity_type_id
SET eav_entity_store.increment_last_id='XXXXXXXXXX'
WHERE eav_entity_type.entity_type_code='invoice';
Al usar nuestro sitio, usted reconoce que ha leído y comprende nuestra Política de Cookies y Política de Privacidad.
Licensed under cc by-sa 3.0 with attribution required.