# ProfitEasy: CLI 명령어, 사용 팁과 문제 해결

> Magento 수익 보고에 필요한 ProfitEasy CLI 명령어, 설정 팁, 자주 발생하는 문제의 해결 방법을 안내합니다.

---

이 페이지는 [ProfitEasy 가이드](/docs/profiteasy)의 일부입니다. 확장 기능의 개요, 설치 방법, 자주 묻는 질문은 기본 가이드를 참고하세요.

## CLI 명령어 {#cli-reference}

ProfitEasy는 관리, 보고서 작성, 연동을 자동화할 수 있는 명령줄 도구를 제공합니다. 최근 추가된 7가지 작업(`costs:list`, `costs:show`, `costs:set`, `sources:list`, `sources:show`, `sources:set`, `order:show-costs`)은 표와 JSON 두 가지 출력 형식을 지원합니다. 기존 작업(`config:check`, `product:show-profit`, `recalculate`, `populate-costs`)은 `--format`을 받지 않으며 항상 사람이 읽기 쉬운 텍스트로 출력합니다.

### 도움말 보기 {#get-help}

```bash
# List available actions
php bin/magento moogento:profiteasy:help

# Detailed help for all options
php bin/magento help moogento:profiteasy
```

### 설정 확인 {#configuration-check}

```bash
php bin/magento moogento:profiteasy --action=config:check
```

ProfitEasy가 활성화되어 있는지와 현재 적용 중인 라이선스 요금제를 표시합니다.

### 상품 수익률 조회 {#product-profit-reporting}

```bash
# Show profit % for a product by ID or SKU
php bin/magento moogento:profiteasy --action=product:show-profit --product_id=42
php bin/magento moogento:profiteasy --action=product:show-profit --product_id=24-UG06
```

### 미설정 상품 원가 채우기 {#product-cost-population}

공급가를 모르는 상품의 원가를 채워야 한다면 이 명령으로 목표 수익률에 맞춰 원가를 설정하세요.

```bash
# Default: 30% margin, prices exclude tax
php bin/magento moogento:profiteasy --action=populate-costs

# Custom margin
php bin/magento moogento:profiteasy --action=populate-costs --margin=40

# Prices include tax
php bin/magento moogento:profiteasy --action=populate-costs --margin=25 --tax=included

# Specific SKUs only
php bin/magento moogento:profiteasy --action=populate-costs --skus=SKU1,SKU2
```

원가 = 가격 × (1 − 수익률 / 100). 원가가 설정되지 않은 상품에만 값을 추가합니다. configurable, bundle, grouped 유형의 상위 상품은 건너뜁니다.

### 주문 수익 다시 계산 {#order-profit-recalculation}

현재 비용 규칙을 적용해 결제가 완료된 주문의 수익을 다시 계산합니다.

```bash
# Recalculate last 15 unprofitable or uncalculated orders (default)
php bin/magento moogento:profiteasy --action=recalculate

# Custom limit
php bin/magento moogento:profiteasy --action=recalculate --limit=100

# Date range (newest first)
php bin/magento moogento:profiteasy --action=recalculate --from="2026-06-10 00:00:00" --to="2026-06-11 23:59:59"

# Force recalculate all eligible orders in range
php bin/magento moogento:profiteasy --action=recalculate --force --limit=100

# Single order by increment ID or entity ID
php bin/magento moogento:profiteasy --action=recalculate --increment_id=100000123
php bin/magento moogento:profiteasy --action=recalculate --order_id=456
```

특정 주문을 직접 지정하면 해당 주문을 처리합니다. 나머지 경우 취소, 종료, 보류 상태인 주문은 제외합니다.

### 비용 규칙 관리 {#cost-rules-management}

CLI에서 비용 규칙을 나열하거나 조회하고 변경할 수 있습니다.

```bash
# List all cost rules
php bin/magento moogento:profiteasy --action=costs:list

# Filter to enabled rules only
php bin/magento moogento:profiteasy --action=costs:list --enabled_only

# Filter by charge type (per_order, per_item, per_payment, currency, time_period)
php bin/magento moogento:profiteasy --action=costs:list --charge_type=per_item

# Machine-readable output
php bin/magento moogento:profiteasy --action=costs:list --format=json | jq .

# Show a specific rule
php bin/magento moogento:profiteasy --action=costs:show --cost_id=7

# Update an existing rule (only specified fields change)
php bin/magento moogento:profiteasy --action=costs:set --cost_id=7 --enable=1 --cost=2.50

# Create a new fixed-cost rule
php bin/magento moogento:profiteasy --action=costs:set --label="Pick fee" \
  --charge_type=per_item --calculation_type=fixed --cost=0.35 --enable=1

# Create a percentage cost rule for a specific payment method
php bin/magento moogento:profiteasy --action=costs:set --label="Payment gateway fee" \
  --charge_type=per_payment --payment=paypal_express --calculation_type=percent --cost=2.9 --enable=1

# Preview changes without writing to database
php bin/magento moogento:profiteasy --action=costs:set --cost_id=7 --cost=2.50 --dry_run
```

**지원하는 부과 유형** `per_order`, `per_item`, `per_payment`, `currency`, `time_period`\
**계산 유형** `fixed`, `percent`\
**세금 처리** `nothing`, `default`(전역 세율 사용), `custom`(`--taxed_custom=<rate>` 필요)

비용 규칙을 추가하거나 변경하면 영향을 받는 주문에 재계산 표시가 붙어 최신 비용이 수익에 반영됩니다.

### 유입 경로 규칙 관리 {#traffic-source-rules-management}

관리자 화면에 접속하지 않고 유입 경로를 판정하는 규칙을 만들거나 수정할 수 있습니다.

```bash
# List all source rules
php bin/magento moogento:profiteasy --action=sources:list

# Enabled rules only
php bin/magento moogento:profiteasy --action=sources:list --enabled_only --format=json

# Show details of a specific rule by ID
php bin/magento moogento:profiteasy --action=sources:show --source_id=3

# Show all rules matching an identifier
php bin/magento moogento:profiteasy --action=sources:show --identifier=smartcart

# Show usage count since a specific date (scans last 100K order rows)
php bin/magento moogento:profiteasy --action=sources:show --identifier=smartcart \
  --count-since="2026-07-01 00:00:00"

# Update an existing rule
php bin/magento moogento:profiteasy --action=sources:set --source_id=3 --enable=1 --priority=5

# Create a new UTM-based source rule
php bin/magento moogento:profiteasy --action=sources:set --create \
  --identifier=newsletter --label="Newsletter" \
  --utm_source=newsletter --utm_medium=email --enable=1

# Disambiguate with --source_id when multiple rows match
php bin/magento moogento:profiteasy --action=sources:set --source_id=5 --priority=10
```

`--identifier`는 서로 다른 UTM 조합에 대응하는 여러 데이터베이스 행과 일치할 수 있습니다. 일치하는 행이 여럿일 때는 `--source_id`로 수정할 행을 선택해야 합니다.

### 주문별 비용 내역 조회(읽기 전용) {#order-cost-breakdown-read-only-reporting}

주문 수익을 산정하는 데 쓰이는 세부 비용을 조회합니다. 이 작업은 수익을 다시 계산하거나 데이터를 변경하지 않습니다.

```bash
# Single order by increment ID
php bin/magento moogento:profiteasy --action=order:show-costs --increment_id=100000123

# Single order by entity ID
php bin/magento moogento:profiteasy --action=order:show-costs --order_id=456

# Date range (newest first, default 15 orders, max 100)
php bin/magento moogento:profiteasy --action=order:show-costs \
  --from="2026-07-01 00:00:00" --to="2026-07-31 23:59:59" --limit=50

# Machine-readable output
php bin/magento moogento:profiteasy --action=order:show-costs --order_id=456 --format=json
```

현재 규칙으로 계산한 수익과 저장된 수익을 나란히 표시하고, 비용 규칙이 바뀌어 값이 달라진 경우 이를 표시합니다. 감사나 문제 해결에 활용할 수 있도록 주문별 비용 내역도 출력합니다. **고객 이름, 이메일 주소, 실제 주소는 출력하지 않습니다.**

---

## 사용 팁과 권장 사항 {#tips-best-practices}

- 수익 지표를 사용하기 전에 비용 규칙부터 설정하세요. 비용이 0으로 기록되어 있으면 매출액 전체가 수익으로 표시됩니다.
- 설치 직후 **Default: Shipping cost for Free Shipping**에 실제 배송 비용을 입력하세요. 무료 배송 주문이 많을수록 비용을 입력하기 전까지 수익이 실제보다 크게 표시됩니다.
- 캠페인을 자주 진행해 유입 경로의 유효기간을 짧게 두려면 **Source: Validity period**를 줄이세요. 기본값 31일을 적용하면 1월에 Google 광고를 클릭했다가 2월에 구매한 고객의 주문도 해당 광고의 성과로 집계될 수 있습니다.
- 주문 그리드의 기기 열을 활용해 모바일 전환에 문제가 있는지 확인하세요. 모바일 방문이 많은데 데스크톱 주문이 대부분이라면 모바일 결제 과정에서 불편을 겪고 있을 수 있습니다.
- 수익 열람 권한은 ACL에서 필요한 역할에만 부여하세요. 대시보드와 고객 프로필의 위젯은 역할별로 숨길 수 있어 일부 팀원만 재무 데이터에 접근하도록 설정할 수 있습니다.
- 비용 규칙을 일괄 변경한 뒤 주문 수익을 비교하려면 10분마다 실행되는 다음 cron 작업을 기다리세요.

---

## 문제 해결 {#troubleshooting}

### 주문에 수익이 표시되지 않음 {#profit-figures-are-not-appearing-on-orders}

모듈을 활성화한 후에도 주문 그리드의 수익 값이 비어 있거나 표시되지 않습니다.

- **원인** 수익을 계산하는 cron이 아직 실행되지 않았거나 주문 처리 큐 컨슈머가 중단되었습니다.
- **확인** `var/log/moogento_profiteasy.log`에서 최근 작업을 확인하세요. `php bin/magento cron:run`을 직접 실행하면 계산을 즉시 시작할 수 있습니다. `bin/magento queue:consumers:list`로 Magento 큐 컨슈머도 확인하세요.
- **해결** Magento cron이 설정되어 있고 실행 중인지 확인하세요. ProfitEasy에는 최소 `*/10 * * * *`의 실행 빈도가 필요합니다. 큐 컨슈머가 중단됐다면 재시작하거나 서버의 프로세스 관리 도구에 추가하세요.

---

### 고객의 CLV와 AOV가 갱신되지 않음 {#customer-clv-and-aov-are-not-updating}

고객 프로필의 CLV와 AOV가 0으로 표시되거나 최신 값으로 바뀌지 않습니다.

- **원인** 밤에 실행되는 고객 데이터 갱신 cron 작업이 중단되었거나 주문에 대해 인보이스를 발행하지 않았습니다.
- **확인** `var/log/moogento_profiteasy.log`에서 `[UpdateCustomerData`를 검색하여 `UpdateCustomerData`가 최근에 실행되었는지 확인하세요. CLV는 인보이스를 발행한 주문만 반영하므로 해당 주문에 인보이스가 있는지도 확인하세요.
- **해결** cron이 예약되어 있는지 확인하세요. CLV 기능은 Growth 또는 Pro 요금제가 필요합니다. 요금제는 Stores > Configuration > Moogento > License에서 확인할 수 있습니다.

---

### 모든 주문의 유입 경로가 “Direct”로 표시됨 {#traffic-source-attribution-is-showing-direct-for-all-orders}

분석 도구에 UTM 매개변수가 표시되는데도 모든 주문이 직접 유입으로 집계됩니다.

- **원인** 리퍼러 쿠키를 수집하지 못했거나 유입 규칙이 들어온 UTM 값과 일치하지 않습니다. 주문이 완료되기 전에 **Source: Validity period**가 끝났을 수도 있습니다.
- **확인** 스토어 URL에 `?moo_debug=1`을 추가한 뒤 `var/log/moogento_profiteasy.log`에서 수집한 리퍼러 데이터를 살펴보세요. Sources 설정 그룹에서 해당 규칙이 활성화되어 있고 패턴이 올바른지도 확인하세요.
- **해결** 실제 사용하는 UTM 구조에 맞게 규칙 패턴을 변경하세요. 대체로 첫 클릭에서 구매까지 31일 넘게 걸린다면 유효기간을 늘리세요. UTM이 없는 자연 검색 또는 AI 유입에 규칙이 적용되지 않으면 해당 규칙의 **UTMs optional**이 켜져 있는지 확인하세요. 이 설정이 꺼져 있으면 UTM이 없는 방문의 규칙 점수가 내려가 일치하지 않습니다. 유입 경로 추적은 Growth 또는 Pro 요금제에서 제공됩니다.

---

### 대시보드에 수익 위젯이 표시되지 않음 {#dashboard-profit-widgets-are-missing}

설정에서 활성화했지만 관리자 대시보드에 수익 또는 AOV 타일이 나타나지 않습니다.

- **원인** 설정을 변경한 후 캐시를 비우지 않았거나 관리자 역할에 필요한 ACL 권한이 없습니다.
- **확인** `php bin/magento cache:clean`을 실행하세요. System > User Roles에서 해당 관리자의 역할에 ProfitEasy 대시보드 접근 권한이 부여되어 있는지 확인하세요.
- **해결** 캐시를 비우고 위젯이 여전히 보이지 않으면 라이선스 요금제를 확인하세요. AOV 위젯에는 Pro가 필요합니다.

---

### 카탈로그 그리드의 상품 수익률 열이 비어 있음 {#product-profit-column-shows-no-data-in-the-catalog-grid}

**Enable Product Profit % Column**을 Yes로 설정해도 열에 값이 나타나지 않습니다.

- **원인** 밤에 실행되는 `UpdateProfitPercentQueue` cron이 아직 실행되지 않았거나 스토어에서 Pro 요금제를 사용하지 않습니다.
- **확인** Stores > Configuration > Moogento > License에서 요금제를 확인하세요. Pro를 사용 중이면 `var/log/moogento_profiteasy.log`에서 최근 cron 작업을 확인하고 `php bin/magento cron:run`을 직접 실행하세요.
- **해결** 오전 1시의 야간 cron 실행을 기다리거나 직접 실행하세요. Seed 또는 Growth를 사용 중이라면 Pro로 업그레이드하세요.

---

### 30일 합계가 7일 합계보다 작게 표시됨 {#the-30-day-total-appears-lower-than-the-7-day-total}

수익 대시보드의 30일 합계가 7일 합계보다 작거나 두 값이 서로 맞지 않습니다.

- **원인** 환불 주문의 기존 수익 계산에서 `base_total_refunded`를 차감하지 않아 비교 기준인 과거 기간의 수익이 실제보다 크게 기록되었습니다.
- **확인** `var/log/moogento_profiteasy.log`를 보고 `ResetRefundedOrdersProfit` 데이터 패치가 적용되었는지 확인하세요. 최근에 모듈을 업데이트했다면 `php bin/magento setup:upgrade`를 실행하세요.
- **해결** `php bin/magento setup:upgrade`로 데이터 패치를 적용하면 과거 환불 주문의 계산 완료 표시가 초기화됩니다. 다음 `UpdateProfit` cron 작업에서 올바른 값을 다시 계산합니다. 이 작업은 10분마다 실행됩니다.

---

### 악성코드 검사기가 Helper/Moo.php를 탐지함 {#malware-scanner-flags-helpermoophp}

- 원인: 호스팅 서비스의 악성코드 검사기(cPanel의 Imunify360 등)가 패턴을 분석하는 과정에서 유료 Moogento 확장 기능에 포함된 인코딩된 라이선스 확인 파일을 탐지할 수 있습니다. 원본 파일은 정식 배포된 그대로이며, 인코딩은 라이선스 확인 부분이 변조되지 않도록 보호합니다.
- 해결: [라이선스 파일 보호 가이드](../magento-guides/moogento-license-file-protection.md)에 따라 파일이 Moogento가 배포한 원본과 바이트 단위로 일치하는지 확인하세요. 가이드에는 검사 경고를 끄기 위해 해당 파일을 제외 목록에 추가하는 방법과 이미 격리된 파일을 복원하는 방법도 나와 있습니다.

---

## 이 가이드의 관련 페이지 {#other-pages-in-this-guide}

- [ProfitEasy 개요, 설치, 자주 묻는 질문](/docs/profiteasy)
- [ProfitEasy: 비용 규칙, 유입 경로 추적과 설정 작업](/docs/profiteasy-setup-tasks)

<!-- docs-split: part-of="profiteasy" -->
